How to receive strings with spaces in scanf()

Answer Posted / vignesh1988i

#include<stdio.h>
#include<conio.h>
void main()
{
char a[50];
printf("enter the string :");
for(int i=0;1;i++)
{
scanf("%c",&a[i]);
if(a[i]=='\n')
a[i]='\0'
break;
}
for(i=0;a[i]!='\0;i++)
printf("%c",a[i]);
getch();
}

Is This Answer Correct ?    4 Yes 3 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Not all reserved words are written in lowercase. TRUE or FALSE?

725


Are negative numbers true in c?

604


What is #include called?

575


Read the following data in two different files File A: aaaaaaaadddddddd bbbbbbbbeeeeeeee ccccccccffffffff File B: 11111111 22222222 33333333 By using the above files print the following output or write it in the Other file as follows aaaaaaaa11111111dddddddd bbbbbbbb22222222eeeeeeee cccccccc33333333ffffffffffff

2246


List some of the static data structures in C?

766






How can I sort a linked list?

639


What is an array in c?

599


what is the basis for selection of arrays or pointers as data structure in a program

3793


What is the explanation for cyclic nature of data types in c?

652


How can I recover the file name given an open stream?

556


Is linux written in c?

603


What is structure in c definition?

579


Explain logical errors? Compare with syntax errors.

633


What are static variables in c?

633


write a c program to print the next of a particular no without using the arithmetic operator or looping statements?

3192