real help !

real help !

Post by SirEklipse on Thu Dec 30, 2010 3:36 pm
([msg=51373]see real help ![/msg])

Hello , this is my 2nd request ! I`ve forgott about Python , and i really REALLY want to begin with C++ . I know i am capable of learning it .. .

I have searched for C++ builder ALL THIS DAY !! i`m so anxious and nervous cuz` i didn`t find anything good . Belive me , i swear of God i search it , nothing good .. only trials and it doesn`t work for me .. i don`t know . I think there are missing files . Please , direct me for a link , just one ! No rude pls , don`t slap me , i`m just so nervous i couldn`t find one good all day . Thank you
SirEklipse
New User
New User
 
Posts: 8
Joined: Tue Dec 28, 2010 2:45 am
Blog: View Blog (0)


Re: real help !

Post by Defience on Thu Dec 30, 2010 3:48 pm
([msg=51374]see Re: real help ![/msg])

User avatar
Defience
Addict
Addict
 
Posts: 1281
Joined: Thu Jun 12, 2008 3:16 pm
Blog: View Blog (0)


Re: real help !

Post by SirEklipse on Thu Dec 30, 2010 4:09 pm
([msg=51377]see Re: real help ![/msg])

I downloaded that , it`s pretty good , but i can`t view my results. I save it , i make it .exe , and if i double click on it , it`s just BLINK , very fast .. and i can`t see anything . It about this file ?

The executables compiled by Dev-C++ will need MSVCRT.DLL (comes with Windows 95 OSR 2 or higher).

I read on that site .. i thought it`s about this . If this is the problem , where can i find it ?
SirEklipse
New User
New User
 
Posts: 8
Joined: Tue Dec 28, 2010 2:45 am
Blog: View Blog (0)


Re: real help !

Post by nathandelane on Thu Dec 30, 2010 5:47 pm
([msg=51381]see Re: real help ![/msg])

SirEklipse wrote:I downloaded that , it`s pretty good , but i can`t view my results. I save it , i make it .exe , and if i double click on it , it`s just BLINK , very fast .. and i can`t see anything . It about this file ?


DevC++ doesn't show you your results by default, so you need to add:

Code: Select all
#include <cstdlib>
...
int main(int argc, char* argv[])
{
...
   system("pause");
...
}

to the end of your main method (see: Things to Avoid in C/C++ -- system("pause")...). If you are using a C compiler (instead of C++), then change <cstdlib> to <stdlib.h>

For example:

Code: Select all
#include <iostream>
#include <cstdlib>

int main(int argc, char* argv[])
{
        std::cout << "This is a test...";

        system("pause");

        std::cout << "That was the test!" << std::endl << std::endl;

        return 0;
}
Me, Nathandelane, Highly influential to Hackerdom, Premature Optimization=http://c2.com/cgi/wiki?PrematureOptimization
User avatar
nathandelane
Poster
Poster
 
Posts: 204
Joined: Thu Jun 26, 2008 11:26 am
Location: Utah
Blog: View Blog (0)


Re: real help !

Post by fabianhjr on Thu Dec 30, 2010 7:15 pm
([msg=51384]see Re: real help ![/msg])

OMG hell no. Don't follow his advice. Just put a
Code: Select all
cin.get()
at the end of main or run it with a terminal like cmd.exe
Donate bitcoins to me! [1DhRP3hHgmSLQdRTZyT8VPTmzAj7Z2rsGA]
Dunno what bitcoins are? BitcoinMe
fabianhjr
Poster
Poster
 
Posts: 286
Joined: Tue Sep 21, 2010 7:48 pm
Blog: View Blog (0)


Re: real help !

Post by Goatboy on Thu Dec 30, 2010 8:02 pm
([msg=51388]see Re: real help ![/msg])

Agreeing with fabi here. cin.get() is a lot cleaner, more portable, and faster than system("PAUSE"). What I fail to understand is why you would recommend this method and then link to an article explaining why NOT to use it!

In addition, there are two things you could do to make your above code look cleaner. First off, if you plan on using cout a lot you should really declare usage for it. Put "using std::cout" at the top so you can just type "cout" instead of "std::cout" which looks a lot nicer. You could also just include the entire std namespace, but that might be overkill and could cause problems with other custom classes, methods, etc.

Another thing to do is to stop using endl in the context that you did. If you simply want to put two newlines, I'd just use "\n\n" since it is shorter, doesn't require another << stream, and doesn't flush the output buffer (not needed in this case).

I know you probably weren't writing this with the intention of anyone criticizing it, but take this as a lesson. This is how I would have done it (with only the changes mentioned):

Code: Select all
#include <iostream>
#include <cstdlib>

using std::cout;

int main(int argc, char* argv[])
{
    cout << "This is a test...";
    cin.get();
    cout << "That was the test!\n\n";

return 0;
}


Try compiling it. Not only does it avoid the ugly "PRESS ANY KEY I AM WINDOWS SUCK MY DICK" message, but the code itself is a lot easier to read. Granted, this will only accept the Enter key, but that's a small price to pay, and (in my opinion) more desirable in most cases.

http://www.cplusplus.com/forum/beginner/25538/
http://stackoverflow.com/questions/2139 ... dendl-vs-n
http://cppkid.wordpress.com/2008/08/27/ ... o-stdendl/
Assume that everything I say is or could be a lie.
1UHQ15HqBRZFykqx7mKHpYroxanLjJcUk
User avatar
Goatboy
Expert
Expert
 
Posts: 2823
Joined: Mon Jul 07, 2008 9:35 pm
Blog: View Blog (0)


Re: real help !

Post by SirEklipse on Sat Jan 01, 2011 5:01 am
([msg=51465]see Re: real help ![/msg])

It works ! Well , amazing answers and very very interesting results on this topic. I found this site more useful then google itself and i don`t want to be rude . Thnk you all for the answers , i found the answer on mIRC , the answer with : system("pause"); . But , the cin.get(); it`s overpower :) Thank you , and thanks for the links but i already have those saved in firefox :) + 1 . I hope , on future if i`m stuck , to get the same answers if i post . Happy New Year , and have a nice day !
SirEklipse
New User
New User
 
Posts: 8
Joined: Tue Dec 28, 2010 2:45 am
Blog: View Blog (0)



Return to C and C++

Who is online

Users browsing this forum: No registered users and 0 guests