I need help!
In this program, if you hit the ENTER KEY the program will display the word "newline".
If you hit the SPACE BAR it will display the word "spacebar".

But unfortunately, the second statement did'nt worked (SPACE BAR).

help me....

#include<stdio.h>
main()
{
char n;
scanf("%c",&n);
 if(n='\n')
         printf("newline..");
 else if(n=' ')
         printf("spacebar");
else
         printf("not");
}

Comparison is done with a == b , assignment is done with a = b .

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.