本文介绍了这是为什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 29岁程序员,3月因学历无情被辞! 我知道造成这个问题的原因是什么,但我无法找到原因。 #define newline" \ n" #define question_mark" \?" #define single_quotas" \''" #define double_quotas" \"" #define form_feed" \f" #define horizontal_tab" \t" #define vertical_tab" \v" #define反斜杠" \\" #include< stdio.h> main(){ int var; printf("键入数字:"); scanf(" ;%d",& var); printf(" the number is"); printf("%d",var); printf(换行符); char * var2; printf(" Type a string:"); int bytes_read = 0; int nbytes = 100; var2 =(char *)malloc(nbytes + 1); bytes_read = getline(& var2,& nbytes,stdin); if(bytes_read == -1) {puts(" ERROR!:invalid)输入");} printf(字符串是); printf("%s",var2); printf(换行); }I know what is causing the problem, but I couldn''tfind out why.#define newline "\n"#define question_mark "\?"#define single_quotas "\''"#define double_quotas "\""#define form_feed "\f"#define horizontal_tab "\t"#define vertical_tab "\v"#define backslash "\\"#include <stdio.h>main(){int var;printf("Type a number:");scanf("%d",&var);printf("The number is ");printf("%d",var);printf(newline);char *var2;printf("Type a string:");int bytes_read=0;int nbytes = 100;var2 = (char *) malloc (nbytes + 1);bytes_read = getline (&var2, &nbytes, stdin);if(bytes_read == -1){puts ("ERROR!: invalid input");}printf("The string is ");printf("%s",var2);printf(newline);}推荐答案 free()var2。除此之外:为什么使用printf()给予 a''\ n''。 请生成编译为 $的代码b $ b gcc -ansi -pedantic 然后回来。 - 迈克尔free() var2. Apart from that: Why use printf() for givinga ''\n''.Please produce code that compiles forgcc -ansi -pedanticand then come back.--Michael 这是哪个问题? Brian RodenbornWhich problem is that?Brian Rodenborn 这篇关于这是为什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云!