0

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");
}

Edited by Narue: added code tags

2
Contributors
1
Reply
3
Views
6 Years
Discussion Span
Last Post by Narue
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.