Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Login         

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


Akhil
getchar()
2 Answer(s)      4 years and 11 months ago
Posted in : Development process


When i write he following program in C using turboC compiler, program repeatedly asks me to input, i want the program to take input once, show the result and stop, pleae help.

#include<stdio.h>
main() {
int c;
while( (c=getchar())!=EOF) { putchar(c); }
}

Advertisement
View Answers

February 9, 2010 at 11:52 AM


#include<stdio.h>
#include<conio.h>
void reverse(void)
{
char c;
if((c=getchar())!='\n')
reverse();
putchar(c);
return;
}
void main()
{
clrscr();
printf("\nEnter the line whatever u want to reverse:");
reverse();
getch();
}


February 9, 2010 at 11:53 AM


Hi Friend,

Try the following:

#include<stdio.h>
#include<conio.h>
void main() {
char c;
c=getchar();
putchar(c);
getch();
}

Thanks


Related Tutorials/Questions & Answers:
Advertisements
 

 

 

DMCA.com