Closed. This question is off-topic。它当前不接受答案。
                            
                        
                    
                
                            
                                
                
                        
                            
                        
                    
                        
                            想改善这个问题吗? Update the question,所以它是on-topic,用于堆栈溢出。
                        
                        6个月前关闭。
                                                                                            
                
        
我正在考虑尝试特殊的控制台功能cscanf()和cprintf(),但以下代码无法编译

#include<stdio.h>
#include<conio.h>
  int main()
{
     int a,b;
     cprintf("Enter two integers\n");
     cscanf("%d%d",&a,&b);
     cprintf("%d+%d=%d",a,b,a+b);
     return 0;
}


这是错误消息:

undefined reference to 'cscanf'
undefined reference to 'cprintf'

最佳答案

gcc不包括非标准头文件conio.h或它声明的函数,当使用标准C并检查实际成功时,它看起来像这样:

#include<stdio.h>

int main() {
     int a, b;
     printf("Enter two integers\n");
     if(scanf("%d%d", &a, &b) == 2) {
         printf("%d+%d=%d\n", a, b, a+b);
     } else {
         puts("you failed to input two integers");
     }
     return 0;
}

关于c - 程序由于cscanf()和cprintf()而无法编译,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/57758791/

10-10 21:28