Reply
Thread Tools
Posts: 279 | Thanked: 34 times | Joined on Jan 2010 @ Belgrade, Serbia
#1
Maybe this question will sound stupid to you, but i just started to learn C++ so i don't know much about it. If you know how to do it, please answer. And one more question, how do you put text in if statements instead of numbers? E.g.
if (x == 10)
cout << 25 << endl;
Now, how can i enter some word instead of 10?
 
joppu's Avatar
Posts: 780 | Thanked: 855 times | Joined on Sep 2009 @ Helsinki, Finland
#2
.exe is a compiled file. You need to get the source code of the application.
 
Posts: 279 | Thanked: 34 times | Joined on Jan 2010 @ Belgrade, Serbia
#3
Originally Posted by joppu View Post
.exe is a compiled file. You need to get the source code of the application.
Where can i get it?
 
Posts: 755 | Thanked: 406 times | Joined on Feb 2008 @ UK
#4
Originally Posted by white_ranger View Post
Where can i get it?
If the application is open source, then wherever you got the original executable from.

Originally Posted by white_ranger View Post
And one more question, how do you put text in if statements instead of numbers? E.g.
if (x == 10)
cout << 25 << endl;
Now, how can i enter some word instead of 10?
Use speech-marks.
e.g.
Code:
if (x == "ten")
Some free c++ programming books.

Last edited by codeMonkey; 2010-01-30 at 17:00.
 
Posts: 61 | Thanked: 21 times | Joined on Jan 2010
#5
Code:
if (x == "ten")
I think using strcmp is more appropriate
 
Posts: 1 | Thanked: 0 times | Joined on Oct 2009
#6
You can't make changes to an executable (well, technically you could, if you disassemble it, etc.).
You need to have the source code for it. That's why many people like open source software -- the source code is available, hence the name "open source".
And if you're talking about an .exe file, it's presumably a Windows binary. Even if you have the source code for it, you may not be able to build it for linux/maemo, without some porting work.

Use strcmp to compare strings, e.g.
if (strcmp(x, "ten") == 0)

The gtk/glib or qt libraries also have a lot of utility functions (string handling, parsing, etc.). Check them out.
C/C++ by itself does not provide that much functionality in the standard libraries (compared to python).
 
Reply


 
Forum Jump


All times are GMT. The time now is 06:37.