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

Write a program to display all the prime nos from 1 to 1000000, your code should not take time more than a minute to display all the nos.

1792


Is c language still used?

727


Explain what’s a signal? Explain what do I use signals for?

788


What are the different data types in C?

941


What is the use of extern in c?

838


What is substring in c?

858


What is the acronym for ansi?

803


write a program to find the given number is prime or not

4278


What is the -> in c?

781


write a c program to do the following: a) To find the area of a triangle. b) To convert the temperature from Fahrenheit to Celsius. c) To convert the time in hours : minutes : seconds to seconds.

1752


shorting algorithmS

2016


write a c program for swapping two strings using pointer

2318


What is the purpose of main() function?

932


What are the types of data types and explain?

853


what is diffrence between linear and binary search in array respect to operators?what kind of operator can be used in both seach methods?

1663