Welcome to Dream.In.Code
Become a C++ Expert!

Join 136,926 C++ Programmers for FREE! Get instant access to thousands of C++ experts, tutorials, code snippets, and more! There are 1,823 people online right now. Registration is fast and FREE... Join Now!




read a leading white space in c

 
Reply to this topicStart new topic

read a leading white space in c, read a white space and print it, so that it can not be ignored

baby83
16 Mar, 2008 - 02:28 PM
Post #1

New D.I.C Head
*

Joined: 16 Mar, 2008
Posts: 1

How can i read a white space without ignoring it. Also it has to printed. for example

#this is figure 1
Figure a
a 100 100

the space before Figure has to be read and then printed.
I have tried sscanf but did not work.
User is offlineProfile CardPM
+Quote Post

no2pencil
RE: Read A Leading White Space In C
16 Mar, 2008 - 05:27 PM
Post #2

My fridge be runnin OH NOEZ!
Group Icon

Joined: 10 May, 2007
Posts: 6,495



Thanked: 66 times
Dream Kudos: 2425
Expert In: Goofing Off

My Contributions
I don't see a space before Figure. I'm a little confused by your question, can you please elaborate?
User is online!Profile CardPM
+Quote Post

bodom658
RE: Read A Leading White Space In C
16 Mar, 2008 - 08:24 PM
Post #3

D.I.C Head
**

Joined: 22 Feb, 2008
Posts: 154



Thanked: 5 times
My Contributions
you will want to use getchar(); instead of scanf(), so something like:
cpp

int c;

while((c = getchar()) != '\n')
putcharŠ;


This post has been edited by bodom658: 16 Mar, 2008 - 08:26 PM
User is offlineProfile CardPM
+Quote Post

Reply to this topicStart new topic
Time is now: 12/3/08 10:20PM

Live C++ Help!

C++ Tutorials

Reference Sheets

C++ Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month