ALLInterview.com :: Home Page KalAajKal.com
 Advertise your Business Here     
Browse  |   Placement Papers  |   Company  |   Code Snippets  |   Certifications  |   Visa Questions
Post Question  |   Post Answer  |   My Panel  |   Search  |   Articles  |   Topics  |   ERRORS new
   Refer this Site  Refer This Site to Your Friends  Site Map  Bookmark this Site  Set it as your HomePage  Contact Us     Login  |  Sign Up                      
tip   SiteMap shows list of All Categories in this site.
Google
 
Categories  >>  Software  >>  Programming Languages  >>  C
 
 


 

 
 C interview questions  C Interview Questions
 C++ interview questions  C++ Interview Questions
 VC++ interview questions  VC++ Interview Questions
 Delphi interview questions  Delphi Interview Questions
 Programming Languages AllOther interview questions  Programming Languages AllOther Interview Questions
Question
How to receive strings with spaces in scanf()
 Question Submitted By :: Niharika_dash
I also faced this Question!!     Rank Answer Posted By  
 
  Re: How to receive strings with spaces in scanf()
Answer
# 1
using the function 
gets(variable)
 
Is This Answer Correct ?    1 Yes 3 No
Karthik
 
  Re: How to receive strings with spaces in scanf()
Answer
# 2
#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 ?    3 Yes 0 No
Vignesh1988i
 
 
 
  Re: How to receive strings with spaces in scanf()
Answer
# 3
#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 4 No
Parmjeet Kumar
 
  Re: How to receive strings with spaces in scanf()
Answer
# 4
char a[50];
use scanf(" %[^\n]",a);
 
Is This Answer Correct ?    4 Yes 0 No
Valli
 

 
 
 
Other C Interview Questions
 
  Question Asked @ Answers
 
How to write a code for random pick from 1-1000 numbers? The output should contain the 10 numbers from the range 1-1000 which should pick randomly, ie ,for each time we run the code we should get different outputs. NetApp12
What are bit fields? What is their use? Adobe1
write an algorithm to get a sentence and reverse it in the following format: input : I am here opuput: Here Am I note: first letter of every word is capiatlised  2
what is memory leak?  3
Program to write some contents into a file using file operations with proper error messages.  1
How would you find a cycle in a linked list?  2
can we print any string without using terminator? Infosys2
how can i make a program with this kind of output.. Enter a number: 5 0 01 012 0123 01234 012345 01234 0123 012 01 0 Wipro3
What's the difference between calloc() and malloc()?  3
# define prod(a,b)=a*b main() { int x=2; int y=3; printf("%d",prod(x+2,y-10)); } the output of the program is a.8 b.6 c.7 d.none TCS5
True or false: If you continuously increment a variable, it will become negative? 1) True 2) False 3) It depends on the variable type  5
Can u return two values using return keyword? If yes, how? If no, why?  7
difference between i++* and *++i IBM3
write a program for odd numbers?  6
what is the defrenece between structure and union  5
declare afunction pointer to int printf(char *)? HCL1
What is structure packing ? HP1
#include<stdio.h> main() { char s1[]="Ramco"; char s2[]="Systems"; s1=s2; printf("%s",s1); } Find the output CitiGroup4
How the C program can be compiled? HP7
array contains zeros and ones as elements.we need to bring zeros one side and one other side in single parse. ex:a[]={0,0,1,0,1,1,0,0} o/p={0,0,0,0,0,1,1,1} Motorola7
 
For more C Interview Questions Click Here 
 
 
 
 
 
   
Copyright Policy  |  Terms of Service  |  Help  |  Site Map 1  |  Articles  |  Site Map  |   Site Map  |  Contact Us interview questions urls   External Links 
   
Copyright © 2007  ALLInterview.com.  All Rights Reserved.

ALLInterview.com   ::  Forum9.com   ::  KalAajKal.com