错误:使用printf()打印Hello world时未声明'Hello'/ Text
While printing "Hello world", if this error 'Hello' undeclared occurred that means Hello is supplied to the compiler as a variable not as a text/string.
在打印“ Hello world”時 ,如果發生未聲明的錯誤“ Hello” ,則意味著Hello是作為變量而不是text / string提供給編譯器的 。
This is possible only, when starting double quote is missing inside the printf(). To fix this error, you should take care of double quotes; place the constant string/text in double quotes.
僅當在printf()中缺少雙引號時這才可能。 要解決此錯誤,您應該注意雙引號。 將常量字符串/文本放在雙引號中。
Example:
例:
#include <stdio.h>int main(void) {//closing double quote is missing printf(Hello world");return 0; }Output
輸出量
prog.c: In function ‘main’: prog.c:4:9: error: ‘Hello’ undeclared (first use in this function)printf(Hello world");^~~~~ prog.c:4:9: note: each undeclared identifier is reported only once for each function it appears in prog.c:4:15: error: expected ‘)’ before ‘world’printf(Hello world");^~~~~ prog.c:4:20: warning: missing terminating " characterprintf(Hello world");^ prog.c:4:20: error: missing terminating " characterprintf(Hello world");^~~ prog.c:6:1: error: expected ‘;’ before ‘}’ token}^What happens, if we use single quote instead of double code in starting of the text/string?
如果我們在文本/字符串的開頭使用單引號而不是雙代碼會怎樣?
Missing terminating ' character error will be thrown.
缺少終止字符錯誤將被拋出。
How to fix?
怎么修?
To fix this error, close the text/string/Hello within the double quotes.
要解決此錯誤,請關閉雙引號內的text / string / Hello。
Correct code:
正確的代碼:
#include <stdio.h>int main(void) {//closing double quote is missing printf("Hello world");return 0; }Output
輸出量
Hello world翻譯自: https://www.includehelp.com/c-programs/hello-or-text-undeclared-while-printing-hello-world-using-printf-error-in-c.aspx
總結
以上是生活随笔為你收集整理的错误:使用printf()打印Hello world时未声明'Hello'/ Text的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: java 的io流需要学吗_Java I
- 下一篇: php 随机两位小数数_使用8086微处