c-strings

    8热度

    2回答

    考虑下面的代码: constexpr auto f() { auto str = "Hello World!"; return str; } int main(int argc, char* argv[]) { static constexpr auto str = f(); std::cout << str << std::endl;

    0热度

    2回答

    我是C语言的新手。我试图使用strcat函数。 #include <stdio.h> #include <string.h> int main(int argc, const char *argv[]) { char s1[] = "12345"; char s2[] = "abcde"; strcat(s1, s2); puts(s1);

    0热度

    3回答

    所以我在读从我的C语言编程过程中的一些代码,和对面这个问题问出来: 修剪字符串:" make trim "到"make trim"。 这是代码: #include <stdio.h> #include <string.h> #define MAX 100 void trim(char *s) { char *d = s; while (isspace(*s++))

    1热度

    3回答

    我有一个格式为:[email protected] [email protected] ... [email protected]的输入字符串。它总是由'@'和' '分隔。 实施例: [email protected] [email protected] [email protected] 它应该显示具有最小值的人的姓名。 如何解决? 输出: driver

    0热度

    1回答

    我有这个项目的问题,我尝试搜索论坛上的答案,但我什么也没找到。 struct orario { int hours; int minutes; int seconds; char *format; }orario1; int main(int argc, char *argv[]) { sscanf(argv[1],"%d:%d:%d %s",&orario1.hours,&ora

    3热度

    4回答

    编辑:我曾尝试改变线arr_of_strings[arr_index_count] = first_word;到strcpy(arr_of_strings[arr_index_count], first_word);但随后它给打印Word is: This 编辑2后分段错误:我我试图做到这一点没有strtok,因为我认为这将是了解C字符串的好方法。 试图学习C我自己。决定创建一个接受字符串的函数,

    1热度

    2回答

    我有这样的代码: char first_word[MAX_LENGTH + 1] = "test"; printf("Word to input: %s\n", first_word); printf("Word to input: %p\n", first_word); 它成功地打印出两个(打印字符串“Test”,然后一个地址)。 在我的代码,我最终做到这一点: char *arr_of

    0热度

    1回答

    我想写一个C程序,我有一个10个字符串的数组,其中每个字符串表示停放在现场i的汽车的车牌号码。随机选取一个地点,如果空置,则生成一个随机车牌号码并将其分配到该地点,如果该地点被占用,则该地点腾空并且车牌号码被删除。但是,该程序正在进入一个无限循环,这正是我想要的,但它不会打印我编写的用于调试程序的任何语句。代码如下: #include <stdlib.h> #include <stdio.h>

    1热度

    2回答

    学习d并彻底享受过程,但这段代码转换成一个d字符串char*我百思不得其解。我无意中发现它的只是一味的直觉模板是如何工作的,但我想知道它是如何工作 import core.stdc.stdio; import core.stdc.string; import core.stdc.stdlib; extern (C): /// Convert a string to a char arr

    -2热度

    1回答

    以下代码时:发生 #define MAX_NAME_LENGHT 256 int main(void) { char name[MAX_NAME_LENGHT]; printf("Enter your name: \n"); scanf("%s", name); if(strncmp(name, "John Smith", 10) == 0)