Click here to Skip to main content
15,892,809 members
Please Sign up or sign in to vote.
3.00/5 (2 votes)
See more:
I have this code that is printing to the DOS screen, I don't want that. I know in VBA it would be:
Dim IP as Int
IP = ("\n   Source      IP: %s", ipSrc);

How would this work in C
printf("\n Source IP: %s", ipSrc);
DS
Posted
Updated 26-Apr-11 6:34am
v2
Comments
Tarakeshwar Reddy 26-Apr-11 12:40pm    
Added pre tags

You can use scanf to store the value in a variable. Take a look here.[^]
 
Share this answer
 
Comments
Member 7766180 26-Apr-11 12:58pm    
Isn't there a simpler way? More like VBA?
DS
Sergey Alexandrovich Kryukov 26-Apr-11 13:08pm    
Forget VBA, the sooner the better!
--SA
Sergey Alexandrovich Kryukov 26-Apr-11 13:07pm    
Sure, a 5.
--SA
Tarakeshwar Reddy 26-Apr-11 14:16pm    
Thank you!
There is no such thing as "DOS screen" in Windows!

There are applications working with console — pure console applications of combining console with a Windowed UI; for example, "CMD.EXE" is just one of them.

—SA
 
Share this answer
 
Comments
Tarakeshwar Reddy 26-Apr-11 12:42pm    
Yeah, op must have got confused with the UI look of the console application.
Sergey Alexandrovich Kryukov 26-Apr-11 13:07pm    
Thank you, Tarakeshwar.

It could be. What I cannot understand: as OP is probably a beginner, she or he may never saw a single DOS system... Why so many people still call this thing a "DOS box", "DOS screen", etc. It's actually a normal protected-mode Win32 or 64-bit application.

--SA
Member 7766180 26-Apr-11 14:04pm    
MERCY! Can't we just call it a DOS BOX for the sake of simplicity instead of a "Normal Protected-Mode Win32 / Win64 Bit Application" ?????
Sergey Alexandrovich Kryukov 26-Apr-11 19:35pm    
No. Call it "Console" -- not much longer than "DOS BOX".
(Well, you can call it whatever you want, but do you need correct understanding and appreciation for accuracy?)
--SA
Tarakeshwar Reddy 26-Apr-11 15:07pm    
I am not sure either. :D
You can use sprintf() function.
char szIP[256];
sprintf(szIP, "\n Source IP: %s", ipSrc);

I'm not so sure if the code snippet above is right for your question.
 
Share this answer
 
Comments
Nish Nishant 26-Apr-11 13:05pm    
Voted 5, proposed as answer.
Member 7766180 26-Apr-11 13:14pm    
When <printf("\n Source IP: %s", ipSrc);\> runs I get... 192.168.1.102
Which is what I want. I want to store this so that I may reference it. I simply want to store this IP address. Can I do this?
INT MyIP
MyIP("\n Source IP: %s", ipSrc);
Nish Nishant 26-Apr-11 13:19pm    
Yes, that's what xnli has told you. Use sprintf. He's even given example code. try it out, and then please mark xnli's response as the accepted answer. Thanks.
Member 7766180 26-Apr-11 13:40pm    
Ok I'm getting closer. Is there a way for a message box to come up so that I can check to see if I am getting the right response?
Nish Nishant 26-Apr-11 13:41pm    
Yeah, there is the MessageBox API. BTW don't use this thread for new questions. Start new threads for new questions.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900