How to receive strings with spaces in scanf()

Answer Posted / parmjeet kumar

#include<stdio.h>
#include<conio.h>
void main()
{
char a[50];
printf("enter the string:");
scanf("%s",&a);
printf("%s",a);
getch();
}

Is This Answer Correct ?    0 Yes 10 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

what is the c source code for the below output? 5555555555 4444 4444 333 333 22 22 1 1 22 22 333 333 4444 4444 5555555555

2784


5 Write an Algorithm to find the maximum and minimum items in a set of ‘n’ element.

1825


Are local variables initialized to zero by default in c?

749


What does sizeof int return?

814


What are the 5 elements of structure?

812


Synonymous with pointer array a) character array b) ragged array c) multiple array d) none

811


What are control structures? What are the different types?

834


In C language what is a 'dangling pointer'?

830


Explain what is a pragma?

786


What is indirection?

835


Explain what does it mean when a pointer is used in an if statement?

823


A variable that is defined in a specified portion of a program but can be used throughout the program a) global variable b) local variable c) character d) none

944


What are linker error?

832


What are the properties of union in c?

804


A banker has a seif with a cipher. Not to forget the cipher, he wants to write it coded as following: each digit to be replaced with the difference of 9 with the current digit. The banker chose a cipher. Decipher it knowing the cipher starts with a digit different than 9. I need to write a program that takes the cipher from the keyboard and prints the new cipher. I thought of the following: Take the input from the keyboard and put it into a string or an array. Go through the object with a for and for each digit other than the first, substract it from 9 and add it to another variable. Print the new variable. Theoretically I thought of it but I don't know much C. Could you give me any kind of hint, whether I am on the right track or not?

1729