It works fine, but just as it appears, it closes..and in the tutorial it shows the console with: 'press any key to continue...' under 'Hello World!'. Please Help!
Name:
Anonymous2006-07-05 20:14 (sage)
either learn how to use windows or switch to a different operating system before you try to learn c++
>>6
TO explain:
Just drag and drop your .exe file onto the black command.com window you have open...
it will run your program and return you to the command prompt.
Thats if you are running windows... if you are using mac/linux just use VI and compile and run from there
Name:
Anonymous2006-07-06 5:20 (sage)
>>8
command.com? Fuck that! cmd.exe ftw (unless your using win9x)
Anyway, I guess you can do it through command line, or you can do it the better way and double-click from explorer, given that you are using the system("pause") method or the dummy character acquisition presented by >>5
Name:
lolz2006-07-06 7:22 (sage)
If you have problems using commandshell programs, you possibly should stop learning a programming language and start learning to use your OS. >_>;;
then add something...i forgot what(lol), it will prompt you to hit any key to continue stuff
use da internet
Name:
Anonymous2006-07-06 11:49
conio.h is a nonstandard library which is pretty pointless for something like this. I would do what a couple people suggested already and run it in a shell...
I'm using MS Visual Studio.net 2005, so I shouldn't have to manually run the program from the console.
>>5
This works, but if I have already used cin, it will exit -due to it getting to that point before releasing the key from the first input. - I can just add a couple of cin's but that would be 'cheating' and generally very bad coding.
>>14
(I actually started with VB6 - which I have come to find inefficient for my needs) - All the C++ tutorials I’ve seen, have been very easy, I just find it annoying that the only way to see the output in the console is to run it in debug mode with a breakpoint at the end.
Name:
Anonymous2006-07-07 18:24
>>17
the problem stems from poor IDE design. if you don't like the way MSVS.net handles console apps, i'd recommend getting a different compiler before i'd recommend screwing with the code itself to get around the issue.
me, i just use a MSYS/MinGW environment for console programs. command line interface for both the compiler and testing the compiled program. happy.
Name:
Anonymous2006-07-07 18:55
When I first got into C++ (shortly before getting right back out of it) I tried some version of Borland that happened to be on the university computers and it automagically inserted GUI code into my app so that my 'Hello, world!' printed into a textbox in a frame.
Name:
Anonymous2006-07-07 20:42
>>17
Hrm, at the end of your program, do something like: cin.ignore(200, '\n');
cin.get()which should work.
Anyway, in both MSVC6 and 2003 .NET, the 'Press any key to continue' comes up automatically.
Name:
Anonymous2006-07-07 20:59 (sage)
>>20
That is, if you use the execute option from the IDE.
Name:
Anonymous2006-07-08 0:27
Just curious though... why is code compiled with msvc2005 usually about 500KB smaller than code compiled under mingw?
Name:
Anonymous2006-07-08 0:28
YOU LOOK LIKE YOU NEED SOME PORN! HOT SHIT!
Name:
Anonymous2006-07-08 0:28
<PORN> DOWNLOAD THIS SHIT NOW YOU RETARDS! </PORN>
Name:
Anonymous2006-07-08 0:29
<PORN> THIRD MESSAGE IN A ROW IN CASE THE FIRST EIGHT DIDn"T GET THE MESAGE THROUGH!
DSAF ASDF ASDF sadf isajef 04w4pju8 8i FUCKING FIX THIS SHIT!
Name:
Anonymous2006-07-08 0:30
stop chimping, chimpy
Name:
Anonymous2006-07-08 0:37
Dear prog,
Related to this, I just figured out something weird. #include <stdlib.h>
#include <stdio.h>
int main(void) {
char text[BUFSIZ];
int i;
puts("enter a number");
if (fgets(text, sizeof(text), stdin) != NULL) {
i = atoi(text);
printf("you entered %d\n", i);
}
return 0;
}When I compile that with MingW, it skips the puts call entirely. I mean I could be doing anything but this happens all the time. Any idea? My code does work. It just comes out like:
$ ./junk
42
enter a number
you entered 42
Name:
Anonymous2006-07-08 1:35
>>27
It is outputting "enter a number" AFTER you enter the number? Sounds like puts is only pushing the string to the buffer, but the buffer isn't getting flushed until printf is called.
Two things, you don't need the /n cause the endl takes care of that for you. Add the line "system("pause");" right before the "return 0;" to make it pause.
>>41
C is not the best for starters but it IS reasonably easy, or at least it doesn't suck. It's one thing to be easy and another thing to be easy to do things with. It's not easy to do string manipulation and higher level stuff in C. But the language itself is easy; I'd say far easier (and smaller) than Python, and it should be, being a low-level language. If C were actually harder than a high-level language supporting good OO, first-class functions, closures, etc., C would be a piece of shit. And it isn't. BTW, that's why C++ IS a piece of shit.
Name:
Anonymous2006-11-18 15:43
>>43
So you are saying C++ sucks just because it is a little more complicated than C because it has has good OO, first-class functions, closures, etc.?
Yes, those added features do make it a little harder, but in the end, they make things easier. It is really not a good idea to evaluate languages on what learning them is like, although it's hard to evaluate them any other way.
Name:
Anonymous2006-11-18 16:28
C++ does not have 'good OO, first-class functions, closures, etc.' It has bad OO and none of the rest.
Way to fail hard.
Name:
Anonymous2006-11-18 17:13
>>45
used all around the scientific and financial world, way to fail hard? I'm rather proud of it
Name:
Anonymous2006-11-18 17:22
You should judge a language based on what can be done with it.
Name:
Anonymous2006-11-18 17:28
>>44 So you are saying C++ sucks just because it is a little more complicated than C because it has has good OO, first-class functions, closures, etc.?
You fail, C++ has none of those.
Here is the C++ code:
#include <iostream.h>
int main() {
cout << "Hello World!\n" << end;
getchar(); // wait for the user to press enter
return 0;
}
Here is the C code:
#include <stdio.h>
int main() {
printf("Hello World!\n");
getchar();
return 0;
}
>>46
No I was saying that YOU fail hard for demonstrating you don't know what you're talking about. Assuming you're >>44. (which you are because Anonymous Anonymous is Anoooonymous)
Name:
Anonymous2006-11-19 6:52
>>53
I work in C++ with scientists, I don't need to prove anything to myself as I see it every day with my own eyes. All my friends have the same experience as I do and I just need to look at the "serious" job offers (not the J2EE crap) to have a proof of what I live. Now stfu and come back once you have some real life experience (being 15 years old does not count)
>>54
If you see closures every day while working with C++ then you're obviously using a completely different language than the C++ everyone else uses. That, or you don't know what a closure is.
Name:
Anonymous2006-11-21 15:43
>>57
where did you saw "closures" in my message, dipshit!
Name:
Anonymous2006-11-22 11:15
>>58 So you are saying C++ sucks just because it is a little more complicated than C because it has has good OO, first-class functions, closures, etc.?