strcpy

    0热度

    2回答

    我有一个问题。 我试图proceede以下步骤: char * str; char * s="Hello"; int len = std::strlen(s); str=new char[len +10]; strcpy_s(str,sizeof(str) ,s); 但PROGRAMM显示错误,这是我在标题写。 如果我用一个数字替换sizeof(str

    0热度

    1回答

    命令行参数排序,我是相当新的C/C++和我学习的命令行参数。我正尝试使用strcpy对我的命令行参数进行排序,但是它给了我不好的输出。 例如 I/P:我 O/P:AMI 我 谁能帮助我什么,我做错了吗?请注意:我只运行这个程序只有argc = 3,并且我只运行这个代码(如上例中所列的那样将被排序)。 我刚刚删除了用于调试的循环。 #include "iostream" #include "cst

    -5热度

    3回答

    我正在学习指针。这段代码正在产生运行时错误。 我想插入字符串在字符数组中使用指针字符。 #include<stdio.h> #include<string.h> int main() { char *a[10]; strcpy(*a,"foo"); }

    -1热度

    1回答

    以下代码将来会删除game.answer的内容,我无法弄清楚原因。 这是结构: typedef struct { int guesses, guessesAllowed; char* answer; char max; } GameState; 这是我的函数建立一个新的结构: GameState makeGame(int guessesAllowed, int

    4热度

    5回答

    我正在做一个练习,其中一个字符指针数组作为存储单词的一种方式。我不明白为什么我不能使用'strcpy'将单词'hoi'复制到主函数中数组的第二个元素。当我编译代码时,我在CodeBlocks中收到'程序已停止工作'的消息。 函数'numberOfWordsInDict'和'printDict'正常工作。 在此先感谢。 int numberOfWordsInDict(char **dict) {

    0热度

    1回答

    我写了一个功能分区进行快速排序算法的元素进行排序cstrings数组 void partition(char words[][MAXWORDLEN + 1], int start, int end, int& partitionIndex) { char pivot[MAXWORDLEN + 1]; //choose last element to be the pivot strcpy(pi

    0热度

    1回答

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

    -1热度

    1回答

    错误的权限我有练习5-13 K & R的问题,练习的目标是制作一个与* nix命令相同的函数尾部,这里是我的功能: #include <stdio.h> #include <string.h> #include "tail.h" int tail(int n) { char *saved_lines[n]; for (int i = 0; i < n; i++)

    -1热度

    1回答

    我有以下问题的数组元素的字符串:我在此节点结构 typedef struct NODE{ struct NODE *sons[1024]; //this array will be used to store children pointers char name[255]; int leaf; }NODE; 和该函数建立具有给定名称的新节点。问

    -1热度

    1回答

    这已得到解答,感谢所有帮助。