Quick links
Latest articles
Internship
Members
New...
Algorithms
Discrete Mathematics
Big data
Languages
C
C++
C++ STL
Java
Data Structure
C#.Net
Android
Kotlin
SQL
Web
PHP
Python
JavaScript
CSS
Ajax
Node.js
Web prog.
Programs
C
C++
DS
Java
C#
Python
Aptitude
C
C++
Java
DBMS
Interview
C
Embedded C
Java
SEO
HR
CS Subjects
CS Basics
O.S.
Networks
DBMS
Embedded Systems
Cloud Computing
Machine learning
CS Organizations
Linux
DOS
More...
Articles
Puzzles
News/Updates

Home » C programs » Common C program Errors

Error: 'Hello'/Text undeclared while printing Hello world using printf()



Here, we will learn why an Error: 'Hello'/Text undeclared while printing Hello world using printf() and how to fix it in C programming language?
Submitted by IncludeHelp, on September 08, 2018

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.

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.

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 " character
  printf(Hello world");
                    ^
prog.c:4:20: error: missing terminating " character
  printf(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.

Correct code:

#include <stdio.h>

int main(void) {
    
	//closing double quote is missing 
	printf("Hello world");

	return 0;
}

Output

Hello world





Quick links:
C FAQ(s) C Advance programs C/C++ Tips & Tricks Puzzles JavaScript CSS Python Linux Commands PHP Android Articles More...

Featured post:
Introduction to Linux (Its modes, Safety, Most popular Applications)
Linux Best Distribution Software (Distros) of 2018

Was this page helpful? Please share with your friends...

Are you a blogger? Join our Blogging forum.

Comments and Discussions



Languages: » C » C++ » C++ STL » Java » Data Structure » C#.Net » Android » Kotlin » SQL
Web Technologies: » PHP » Python » JavaScript » CSS » Ajax » Node.js » Web programming/HTML
Solved programs: » C » C++ » DS » Java » C#
Aptitude que. & ans.: » C » C++ » Java » DBMS
Interview que. & ans.: » C » Embedded C » Java » SEO » HR
CS Subjects: » CS Basics » O.S. » Networks » DBMS » Embedded Systems » Cloud Computing » Machine learning » CS Organizations » Linux » DOS
More: » Articles » Puzzles » News/Updates



© https://www.includehelp.com (2015-2018), Some rights reserved.