473,396 Members | 1,923 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,396 software developers and data experts.

Regarding scanf

Parul Bagadia
188 100+
Probably i know the answer of this ; but i'm not so sure.
Ok, in one program i used newline character('\n') after the format specifier ; and the next line was not getting executed.... untill i enter one more value...
It indicated that; may be because, value gets stored in the memory location only when pointer ; or you may say & sign in case of scanf is used.
Is it because of the same reason; as i thought or something else?
Mar 3 '08 #1
5 1233
weaknessforcats
9,208 Expert Mod 8TB
Let's see the code. A description of the problem can't be used reliably.
Mar 3 '08 #2
Parul Bagadia
188 100+
Here is the code;
ahd below that is the output of that......
after scanf is executed the remaining code doesnt execute.

#include<stdio.h>
#include<conio.h>
void assign();
void check();
int c;
void main()
{
int choise;
do{
printf("\nEnter your choise from the given menu:\n 1.Assign\n 2.Check \n 3.Exit\n");
scanf("\n%d",&choise);
switch(choise)
{
case 1:
assign();
break;
case 2:
check();
break;
case 3:
break;
}
}while(choise!=3);
}
void check()
{
int i;
printf("%d",&c);
i=c+1;
printf("%d",i);
printf("\n%d",&i);
}
void assign()
{
printf("\n Enter the value of c:\n");
scanf("\n%d\n ",&c);
}
Enter your choise from the given menu:
1.Assign
2.Check
3.Exit
1

Enter the value of c:
34





3

Enter your choise from the given menu:
1.Assign
2.Check
3.Exit
Press any key to continue
Mar 3 '08 #3
oler1s
671 Expert 512MB
Go to Google, and type in "man scanf" there. Now read the manual pages that appear. Especially read the portion that tells you what happens when you type in a whitespace character in the format string. FYI, '\n' is whitespace as well.
Mar 3 '08 #4
Parul Bagadia
188 100+
Go to Google, and type in "man scanf" there. Now read the manual pages that appear. Especially read the portion that tells you what happens when you type in a whitespace character in the format string. FYI, '\n' is whitespace as well.
Thanx for that; but can you tell me what is FYI?
Mar 3 '08 #5
oler1s
671 Expert 512MB
Thanx for that; but can you tell me what is FYI?
Sorry, abbreviation for "For your information". I tend to use the abbreviations FYI and NB (Nota Bene) a bit more than I should, I suppose.
Mar 4 '08 #6

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

Similar topics

7
by: Rakesh | last post by:
Hi, I was writing this C++ program wherein I used an include statement like - #include <iostream.h> I was told by my co-worker that this form of including a file is deprecated and should...
12
by: B Thomas | last post by:
Hi, I was reading O'Reilly's "Practical C programming" book and it warns against the use of scanf, suggesting to avoid using it completely . Instead it recomends to use using fgets and sscanf....
7
by: hugo27 | last post by:
obrhy8 June 18, 2004 Most compilers define EOF as -1. I'm just putting my toes in the water with a student's model named Miracle C. The ..h documentation of this compiler does state that when...
8
by: AG | last post by:
Hello, This is my first post to this group, and on top of that I am a beginner. So please direct me to another group if this post seems out of place.... I have recently written a program which...
3
by: Rohini Ramamurthy | last post by:
Hi All, I have taken up this problem to learn a bit in using linked lists. I am trying a variant of it what it is supposed to so is delete the nth person clockwise and counter clockwise...
14
by: main() | last post by:
I know this is the problem that most newbies get into. #include<stdio.h> int main(void) { char a; scanf("%c",&a); /*1st scanf */ printf("%c\n",a); scanf("%c",&a); /*2nd scanf*/...
1
by: nozone | last post by:
Hi all. I am beginner in C. My question is: What is " \n" inside scanf()? Here is part of the implementation of an example: ... char myChar; int myID; scanf("%c", &myChar); scanf("%d\n";...
1
by: nozone | last post by:
Hi. The following is my code of an example: #include <stdio.h> /*line 1*/ main() ...
2
by: phatinc | last post by:
I was writing a program that calculates volume of a triangular prism. However it came to my attention that integers larger than what can be stored will cause errors so I placed certain restrictions...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.