fgets

    0热度

    1回答

    因此,我正在制作一个非常基本的shell,它可以逐行读取内容,并且我遇到了有关循环的问题。 这是我的主: int main(int argc, char* argv[]) { char* av[ARGVMAX]; int nArgs, i, j, k; fflush(stdout); while (fgets(line, LINESIZE, stdin)

    1热度

    1回答

    我是C新手,并且很喜欢学习它,但是我遇到了一个与我的程序有关的问题,我很难尝试弄清楚。在下面的程序中,如果用户输入“1”,则将提示他们输入“密钥”,“年龄”,“名字”和“姓氏”。但是,当用户输入“1”时,程序不会等待用户输入“Key”值,而是直接打印到“Age”。 进入“1”后的输出: 输入以下信息:按键 :年龄: 程序要求之前不会等待用户在一个键值进入,用户输入年龄值。程序编译时不会发生错误或警

    1热度

    1回答

    char theInput[10]; long option; int innerLoop = 1; char *dunno; while(innerLoop == 1){ printf("\nType '1' to get your change, '2' to select another item, or '3' to add more funds: "); fg

    0热度

    1回答

    我在Windows 8.1中使用MinGW,并且我有一个原始数字输入文本文件(每行一个),我想在二进制文件中将它们编写为二进制文件。这个例子是没有问题的编译具有: gcc -pedantic -Os -c my_code.c -o my_code.exe 但输出 $ my_code.exe sh: ./my_code.exe: Bad file number 这是我写的代码: #incl

    5热度

    3回答

    我一直在测试这个结构,我得到关于使用gets的警告。有人提到用fgets代替,并用'\0'代替。任何建议如何改变我的代码来做到这一点? void regCars(Car reg[], int *pNrOfCars) { char again[WORDLENGTH] = "yes", model[WORDLENGTH], tmp[WORDLENGTH]; int year, mi

    -4热度

    1回答

    当我运行这段代码: #include<stdio.h> #include<stdlib.h> int main() { char name , age , gender , male; printf("Please enter your name \n"); fgets(name, 20 ,stdin); printf("Please ente

    -2热度

    1回答

    我面临一个问题,我写这个代码读取文件的每一行的窗口。它在Windows 7中运行良好,但不在liunx中运行。我真的无法弄清楚。任何人都可以帮助我? list< list<string> > getTransRecordsFormFile(const char* fileName) { list< list<string> > res; FILE* f = fopen(fil

    -1热度

    1回答

    我试图从文本文件中读取数据,使用不同的功能,如fgetc(),fgets()和fscanf()。在执行过程中,从fgetc()读取后终止。 #include <stdio.h> void writeFile(FILE *, char *); void readFile(FILE *,char *); void main(void){ FILE *file; char

    -2热度

    1回答

    当我运行下面的代码时,它打印'>',等待输入,然后段错误。有人知道为什么吗? int main(int argc, char **argv){ char input[MAX_INPUT_LINE]; while(1==1){ if (isatty(0)){ printf(">"); } fgets(i

    0热度

    1回答

    当我写下面的代码。腻子打印文本,但我不能键入下面什么.. 例如: 首先,他做了printf - >你是谁? 然后,我做了一个fgets,我通常最喜欢的东西,但doensn't工作。 最后他做了另一个printf他说的地方;很高兴认识你... int main(void) { /* USER CODE END 1 */ /* MCU Configuration-------