473,804 Members | 3,091 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

space trouble......

13 New Member
basically we observed that in order to input 2 character constants at a time we
ought to give spaces....hav a peek in ter dis....
case1

void main( )
{
char a,b;
printf("\n enter 2 characters");
scanf("%c%c",&a ,&b);
printf("\n %c %c ",a,b);
getch( );
}

now the program executes in the following way-it will only take one character as an input and print the same



case2

provided the entire program remains the same and u only introduce spaces in satement no3- scanf("%c %c",&a,&b);
now it takes 2 characters as input and prints both of them



case3

provided the entire program remains the same and we only cahange the 3rd statement ie scanf("%c %c ");note that here we have given a space after the 2nd %c as well...in this case the compiler waits for three characters to be entered b4 printing the output ie the 1st two characters...


there is a vast variation in the execution of the program jst bcoz of the spaces....y does this happen?...
Aug 14 '08 #1
2 1415
Banfa
9,065 Recognized Expert Moderator Expert
case1

void main( )
{
char a,b;
printf("\n enter 2 characters");
scanf("%c%c",&a ,&b);
printf("\n %c %c ",a,b);
getch( );
}

now the program executes in the following way-it will only take one character as an input and print the same
That is not the behaviour I observe, I input 2 characters for this case and it outputs 2 characters.

Program Output
enter 2 charactersab

a b Press any key to continue . . .
If you are pressing return after the first letter you get
enter 2 charactersa

a
Press any key to continue . . .
This is still outputing 2 characters, the 2 characters entered are 'a' and '\n' note the 'Press any key to continue . . .' is on the line below the a this time, the program has read 'a' and '\n' and then output 'a' and '\n' you are just failing to notice it because it is not a printable character.
Aug 14 '08 #2
shweta khare
13 New Member
thank u for clarifying my doubts...
Aug 15 '08 #3

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

Similar topics

21
4033
by: Christian Seberino | last post by:
Linux kernel style guide, Guido's C style guide and (I believe) old K&R style recommends 8 SPACES for indent. I finally got convinced of wisdom of 8 space indentation. Guido also likes 8 space indentation FOR C CODE. Why style guide (PEP-8) for Python says 4 space indents??? Is breaking rule to use 8 space indents everywhere
0
3191
by: Sugapablo | last post by:
I'm having trouble formatting a table properly in MSIE. What I have works in Mozilla and just won't work in MSIE. This is the code: http://www.sugapablo.net/temp/html.txt Here is an image of what's happening: http://www.sugapablo.net/temp/table.png
0
426
by: Pratik Mehta | last post by:
Hi Friends, I am facing trouble with dynamically compiling C# source files. Here is the example: Following command works: csc.exe /out:test.dll /target:library /r:system.dll,Infineon.FD.Repository.S hared.dll /lib:E:\Pratik\FD\SourceCode\RE_TB\GUI\REGUI\bin\Debug\RepositoryBin\ test.cs
27
20068
by: Aurangzeb M. Agha | last post by:
I'm running Postgres 7.1.3, and just started having a problem where my dynamic site is going down (read-only DB, with no writes happening to the DB) regularly (every other day). I have no idea whay this is happening, and my search of the FAQ's and mail list don't bring up anything. i've attached the error from the log file, at the end of this message. Here's an output of the disk usage from within the DB dir $ du -k . 1716 ...
10
8349
by: Shuo Xiang | last post by:
Greetings: I know that variables declared on a stack definitely does not reside in heap space so there is only a very limited amount of stuff that you can store in the stack of a function. But what about the global space? Is that the same as the heap space or is that still a form of special stack? Because once I've seen someone declare a 1 megabyte char array in global space like this: char s;
5
6249
by: Alan | last post by:
Hi, I'm getting as bit confused with my queries. I simply (!) want to insert a space into a postcode field the 4th character from the right, so, for example, ML201TQ becomes ML20 1TQ, which is the post offices format. Unfortunately I've been given a database with postcodes that don't have this space. Thanks
2
10356
by: Jacob.Bruxer | last post by:
Hi everyone, I'm having trouble opening space delimited textfiles in Excel from Visual Basic.net. I'm able to control, open and modify Excel files from Visual Basic, so my Excel reference seems to be working ok. I just don't know what I'm doing when I try to open a space delimited file and want to put the data into columns. I tried recording a macro in VBA and going from there, but then I got stuff saying "Name 'xlDelimited' is not...
10
2092
by: Phil Stanton | last post by:
I have a table of SpaceAreas eg Food Store, Garden Shed etc with the first and last bin for each Space Area defined. eg Food Store First Space 1, last space 26 and Gargen Shed First space 1, last Space 50. SpaceAreas Table is SpaceAreaID Auto SpaceAreaDesc Text FirstSpace Integer LastSpace Integer I have a secont table of the Equipment Stored in each space
0
1547
by: BlueNeck | last post by:
I'm having some trouble with a design I'm working on. There are a few places where I have extra space and I can't isolate the problem. Here's the page: http://www.blueneckdesign.com/css-help/sample1.html and the CSS: http://www.blueneckdesign.com/css-help/style.css Just below the top half of the light bulb image and above the rollover navigation, there is a space of about 3px that shouldn't be there (Mac OSX 10.4.10, and 10.2.8:...
1
4432
by: bdbeames | last post by:
I am currently getting some forecast data from a web site using (file_get_contents), then I'm using explode to put the string in an array, which I am then parsing. The trouble is when I use explode() are several empty elements between each full one. Example. Array ( => this => is => => => a => => => test ) If I print the sting before I explode it I only see one space between each word, but the it seems to be that there is more...
0
9569
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10558
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10302
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10069
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9130
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7608
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6844
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5503
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5636
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.