strcmp

    0热度

    1回答

    我想做一个插入函数,但我不知道我是否被允许在参数中使用char字符串和节点。 这是行不通的?为什么不? void insert(char* str, node* head) { if (head == NULL) { node* new_node = malloc(sizeof(struct node)); assert(new_node != NULL);

    0热度

    1回答

    对于任务,我必须从具有目录列表的文本文件中删除一行。用户输入文件名,包括文件名的目录必须被删除。对于赋值,我必须使用char数组。我有一个问题,strcmp在返回0时返回-13,但只有在应该删除的行之后有另一行时才会发生这种情况。在这里,问题的代码: void deleteSong() { char userSongName[ENTRY_SZ], objectSongName[ENTR

    -2热度

    2回答

    我不明白为什么它在到达行“if(strcmp(next,str2)== 0)return”后立即停止;“ 现在我已注释掉%。*因此我可以完整地打印两个字符串,它们在到达if语句之前进行比较,因此5在我的示例输入中无关紧要。 当我打印两个字符串“下一步”和“STR2”,下面显示 我可以看到字符串“ABC DEF”是不一样的“BC DEFA”,但现在看来,这满足if语句,因为它会停止选取框功能。当我注

    -1热度

    1回答

    char c; char unprocessed_instruction[9]; int i; for (i=0; i<num_tasks; i++){ c = fgetc(fp); int j = 0; while (c != ' '){ unprocessed_instruction[j] = c; j = j + 1;

    1热度

    3回答

    该程序应该创建一个排序列表并按照姓名排序每个用户。我似乎无法弄清楚如何正确排序名称。 我只有append_to_list函数的问题,其余的功能工作正常。 当我第一次开始输入名称: user ID: Last Name: First Name: 3 Alex Alex 2 Jones Alex 1 andrew john ,直到我进入应该排序其间两个名字 ,当我

    1热度

    4回答

    #include <stdio.h> #include <string.h> void main() { char a[10]="123456789"; char b[10]="123456789"; int d; d=strcmp(a,b); printf("\nstrcmp(a,b) %d", (strcmp(a,b)==0) ? 0:1); printf("compare

    1热度

    4回答

    我正在制作一个函数,它可以反转字符串并检查字符串是否是回文。当我用“abba”等明显的回文测试函数时,函数表示它不是回文。前向串和反向串的串长也不同! #include <stdio.h> #include <string.h> char forward [] = "abba"; //The string to be reversed int size = (sizeof(forward

    0热度

    1回答

    在我的游戏中,我跟踪解锁的水平与矢量std::vector<bool> lvlUnlocked_;。 简单的功能,节省的进展是这样的: void save() { std::stringstream ss; std::string stringToSave = ""; std::ofstream ofile("./progress.txt"); if (o

    -1热度

    1回答

    #include <iostream> #include <string> using namespace std; class String { public: String(){ //default value = 0; name = "noname"; } String (int x){ setVa

    -1热度

    1回答

    我得到一个分段错误时,我比较 strcmp(commands[i].cmd[0],"quit") == 0) 和 命令[I]。加利福尼亚[0]是类型char *相关。 并且当 CMD根据我的gdb调试[0] =为0x0 发生这种情况。 现在,当没有字母数字字符存在时,会发生这种情况。例如,一个只有空格的字符串。我将如何避免这种情况。我想检查我的字符串是否至少有一个符号。 这是导致 计划接收信号