putchar

    -1热度

    2回答

    这里是我的代码: #include <stdio.h> #include <string.h> void ignoreRestOfLine(FILE* fp) { int c; while ((c = fgetc(fp)) != EOF && c != '\n'); } int main(void) { int num_times, count =0

    -4热度

    2回答

    我用C编写一个程序,要求用户输入一个数字范围。恩。 1 4 6 9 5并找到它们中最大的一个。这看起来很简单,但我一直得到错误的结果。 到目前为止我的代码我写的是: #include <stdio.h> #include <stdlib.h> main() { char max; int count = 0; char numbers; print

    -2热度

    3回答

    我想用putchar()和getchar()从用户中读取一串字符,然后我的循环将打印每个字符三次,打印新行等等,直到变量“userInput”中的每个字符都已经打印完毕。当我尝试编译我的节目,我收到以下错误: warning: assignment makes pointer from integer without a cast [enabled by default] userInput =

    -3热度

    1回答

    我有一个关于在C中的putchar函数的问题。当我在学习时,我偶然发现以下语句: printf("%c\n",putchar('A'+1)+2); 当我编译和执行程序时,结果是BD。我不敢肯定,当我们输入putchar('A' + 1)的结果将是B,但我们如何得到D?这个函数不一次返回一个字符吗? 在此先感谢

    2热度

    1回答

    我写一个简单的代码来打印文件到标准输出的内容。 当我使用这个: while((c=fgetc(fp))!=EOF)putchar(c); 它像它应该,但我想合并putchar和fgetc。所以我写了 while(putchar(fgetc(fp))!=EOF); 但它似乎没有工作。所以我检查返回值putchar RETURN VALUE fputc(), putc() and

    0热度

    1回答

    我是从GNU libc的手动测试this代码: #include <unistd.h> #include <stdio.h> #include <stdlib.h> #include <termios.h> /* Use this variable to remember original terminal attributes. */ struct termios saved_at

    1热度

    2回答

    我想从终端写入文件中的内容。文件正在创建但内容未写入文件。 #include<stdio.h> #include<stdlib.h> #include<math.h> int main(int argc, char *argv[]) { FILE *fp; fp=fopen(argv[1],"w"); char ch;

    -2热度

    1回答

    大写第一characers我对取得包含有人的名字字符串,并打印出名字的首字母大写代码,每当我跑我的代码,我不断收到两次打印的缩写工作,我不知道如何解决这个问题并获得所需的输出。 这里是我的代码: #include <cs50.h> #include <stdio.h> #include <string.h> #include <ctype.h> int main(void) {

    1热度

    1回答

    我正在通过K & R中的一些练习来工作。练习1-6要求验证表达式getchar() != EOF是0还是1.我理解它的原因,但代码我写信证明它没有按预期工作。我写了下面的两个片段: 版本1: int main(void) { int c; while (c = getchar() != EOF) { putchar(c); } p

    -1热度

    1回答

    Snapshot of the error 正如你可以看到我得到一个链接错误。我控制了printf语句,看起来没什么错,包含头文件。我有点迷失在文件中。也许我可以得到一个以前有过这个问题的人的建议。 在此先感谢。