strncpy

    0热度

    3回答

    如果我有 char str_cp[50],str[50], str_other[50], str_type[50]; strcpy(str,"how are you : i am fine"); strcpy(str_other, "who are you : may be robot or human being"); strcpy(str_type,"type : worker/mana

    0热度

    1回答

    我试图使用strncpy,然后是strcpy,反之亦然,但我在运行时不断收到分段错误。我认为这是因为函数中存在逻辑错误,但我切换了他们的位置,只有第一个执行。 #include <stdio.h> #include <string.h> int main(void) { char c = ' ', sentence[50], *pointer_to_string; po

    0热度

    3回答

    我想我理解了this question的答案,但我不知道。我理解第一个结果,但我仍然不知道如何正确地复制副本。我尝试下面的代码: // TstStrArr.cpp : Defines the entry point for the console application. // #include "stdafx.h" #include <string.h> #include <mall

    0热度

    1回答

    当字符数组substring[#]设置为[64]时,该文件输出一个附加字符。附加字符随每次编译而变化。有时为es?,有时为esx等。 如果我将[64]更改为任何其他号码(至少是我尝试过的号码:65,256,1 ..),它会正确输出为es。 更为奇怪的,如果我离开未使用/未声明的字符数组char newString[64]在这个文件中,它输出的正确子es甚至与64 怎样的64看似随意的大小影响了?

    1热度

    1回答

    说之前使用数组的malloc结构,我有一些结构是这样的: struct address { char city[40]; char street[40]; double numberofhouses; }; struct city { struct address * addresslist; unsigned int uisizeadr

    0热度

    1回答

    我对c编程非常陌生,对于学校作业,我需要编写一个程序以字符串作为输入并将字母“ay”添加到每个词都以这个单词前面的辅音开头。据暗示,这应该用strncpy和strcat来完成。 这是我写的代码: #include <stdio.h> #include <string.h> int main() { char myString[50]; cha

    0热度

    2回答

    我是C新手,编写代码来帮助我进行数据分析。它的一部分打开预定的文件。 这段代码给我的问题,我不明白为什么。 #include <stdio.h> #include <stdlib.h> #include <string.h> #define MAXLOGGERS 26 // Declare the input files char inputfile[]; char inputf

    -1热度

    1回答

    我基本上只是采取一个字符串和追加/ concatting与另一个字符串。第一次运行会产生所需的结果,但第二次,第三次等结果似乎是src字符串的两倍。将事情与jQuery结合起来非常简单,不知道C中发生了什么。我应该使用memset吗?或calloc? #include <stdio.h> #include <string.h> int main(void) { const char

    -2热度

    1回答

    我有两个const char [] PROGMEM变量,我需要连接到另一个const char [] PROGMEM。我对C完全陌生,无法理解如何在previous question上使用strncpy。由于目的地是恒定的并且只读 const char data_one[] PROGMEM = {0x00,0x01,0x02}; const char data_combined[] PROGME

    -3热度

    1回答

    我想编写一个程序,获取字符串'ch1'的前半部分并将其放入字符串'ch3'中,然后获取另一个字符串'ch2'的前半部分并将其连接'CH3' “把在CH 3的端部”,但是当我执行它,它给我要CH3怪异输出.. 例如: ch1 ="123" ch2 ="azertyuiop" 结果: CH3 =“1 < 3rdweirdletter> azert “ 这是我的代码: int main() {