473,408 Members | 2,839 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,408 software developers and data experts.

This problem is really bugging me

I am new here and decided to join a forum in order to help me out with my programming difficulties. Hope i get a reply soon on this

I have been experiencing problems in using the gets() command in C. Whenever I use it twice followed by scanf for eg:

char name[20],add[20];
printf("Enter name : ");
gets(name);
printf("Enter address :");
gets(add);
printf("Enter age :");
scanf("%d",age);

Here it skips name.(doesnot take input of name!)

It doesnot input both the name and address. It skips one of them and this occurs only when i use scanf also. And "scanf" has problem with spaces so i cant use that for strings. Pls help me out!
Jan 21 '07 #1
1 1147
horace1
1,510 Expert 1GB
I am new here and decided to join a forum in order to help me out with my programming difficulties. Hope i get a reply soon on this

I have been experiencing problems in using the gets() command in C. Whenever I use it twice followed by scanf for eg:

char name[20],add[20];
printf("Enter name : ");
gets(name);
printf("Enter address :");
gets(add);
printf("Enter age :");
scanf("%d",age);

Here it skips name.(doesnot take input of name!)

It doesnot input both the name and address. It skips one of them and this occurs only when i use scanf also. And "scanf" has problem with spaces so i cant use that for strings. Pls help me out!
the only obvious error is you have missed the & before age in scanf(), i.e.
Expand|Select|Wrap|Line Numbers
  1. scanf("%d", &age);
  2.  
scanf() requires an address to return the value read into the variable (& beinf the address of operator)
Jan 21 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

10
by: NKOBAYE027 | last post by:
my friends, the end()... hehehe no...nothing so dire... I'm at an impasse I think. I've created the MathematicalSet class as follows - it has 4 lists. An ObjectPool of the actual objects, a...
4
by: Claire | last post by:
My main object has been designed for read/write in a property grid. As I couldn't see a way to make it readonly when I needed to, I created a 2nd skeleton object that exposed the properties of the...
14
by: Marcus | last post by:
I have a function that simply returns TRUE if it can connect to a particular Sql Server 2005 express, or FALSE if it cannot. I am getting some strange error codes returned when the computer that...
8
by: CalebConnolly | last post by:
Hi, ive been reading these forums for a while and just now after reading something that makes no sense to me I thought I might as well ask on here for some help. Basically I was reading through a...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.