C program

robot313
12-12-2001, 04:44 PM
I made the following program with Dev C++:<pre>
#include &lt;stdio.h&gt;

int main()
{
printf("This is output from my first program!\n");
return 0;
}</pre>

but it just comes up and quits so fast, that I can't even see if it works. What's the problem? Don't think I'm dumb or anything, I just started C.

Banjo
12-12-2001, 04:49 PM
Look in the menus for a view output window option. There is a keyboard shortcut but I can't remember what it is.

orufet
12-12-2001, 04:54 PM
If you run your program from a dos console, you can see the output. I've had the same problem with C++. By the way, why learn c instead of c++?

robot313
12-12-2001, 04:59 PM
Banjo: I didn't see that menu option.

orufet: Thanks. And the answer to your question:

From HowStuffWorks (http://www.howstuffworks.com/c.htm):
The jump to the object oriented C++ language becomes much easier. C++ is an extension of C, and it is nearly impossible to learn C++ without learning C first.

Squirm
12-12-2001, 05:02 PM
Quote : 'I made the following program with Dev C++:'

orufet
12-12-2001, 05:02 PM
NOT TRUE!

I've had very little trouble learning C++, with no experience whatsoever in C. They don't know what they're talking about! Come on! I read the FAQ written by Bjarne himself, and he says that's complete crap! No way!

Squirm
12-12-2001, 05:03 PM
C++ = C with 'bits'

orufet
12-12-2001, 05:04 PM
"C++ is an extension of C, and it is nearly impossible to learn C++ without learning C first. "

That's like saying "VB 6 is an extension of VB 5, and it is nearly impossible to learn VB 6 without learn VB 5 first"

NO WAY!

robot313
12-12-2001, 05:08 PM
Squirm: Dev C++ is the name of the program I used to make it. It compiles C and C++.

orufet: I just posted what Marshall Brain said. I don't know, like I said, I just started. And since that article was there about C I thought I'd learn it. Do you know a site with an article on C++?

Banjo
12-12-2001, 05:09 PM
I read Dev C++ as DevStudio C++. Are you using VC++ or is it something else?

orufet
12-12-2001, 05:10 PM
Lots! images/icons/smile.gif

I respect your decision about C, but I will sooner die than accept the idea that C++ is impossible to learn without knowledge of C. That's bull.

robot313
12-12-2001, 05:10 PM
I'm using Bloodshed Dev-C++ Version 4.

Banjo
12-12-2001, 05:12 PM
OK, sorry, my mistake. The menu option I mentioned is in VC++.

robot313
12-12-2001, 05:12 PM
orufet: Then post a few. I'll check them out. Again, that is not my opinion, it is Marshall Brain's.

Banjo
12-12-2001, 05:14 PM
I've found the SAMS books to be very good. However, I'd go to a bookshop and look at them rather than buy over the net becuase they can sometimes get very in depth and are not always ideal for a beginner.

Search the web for tutorials as well. I'm sure that there are loads out there.

orufet
12-12-2001, 05:20 PM
Cprogramming.com: C++ Programming Resources (http://www.cprogramming.com)

MSDN (http://msdn.microsoft.com/visualc/technical/training.asp)

Programmer's Haven (http://www.programmershaven.com)

Programming Tutorials (http://www.programmingtutorials.com)

Want more?

robot313
12-12-2001, 05:38 PM
Thanks. I think these will be fine for now.

robot313
12-12-2001, 07:56 PM
Revised (again)
OK, sorry about all the C stuff, but some of you seem to know about it, so here's another question:
<pre>
<font color=green>#include &lt;iostream.h&gt;</font color=green>
int main()
{
int thisisanumber;
cout&lt;&lt;<font color=red>"Please enter a number:"</font color=red>;
cin&gt;&gt;thisisanumber;
cout&lt;&lt;<font color=red>"You entered: "</font color=red>&lt;&lt;thisisanumber;
return <font color=blue>0</font color=blue>;
}
</pre>
In this C++ program, or any other C++ program that uses &lt;&lt; or &gt;&gt; what are they for?

orufet
12-12-2001, 08:52 PM
I believe it's just an operator that helps the compiler notice that you want input &gt;&gt; or output &lt;&lt;, kind of like ( ) in VB and C...

robot313
12-12-2001, 09:03 PM
Oh, ok. Thanks, orufet, for helping.

Robby
12-13-2001, 01:49 AM
It's been a while but try ...


#include &lt;stdio.h&gt;

int main()
{
printf("This is output from my first program!\n");
getche();

return 0;
}

Banjo
12-13-2001, 03:19 AM
Yeah, they are operator members of the iostream (I think) class.

Yoda
12-13-2001, 04:15 AM
1°) About getche() - I thought it was getch()

2°) A different way to get input and output into your app is by using scanf and printf

It's been some years now since I did C++, so it might not be that perfect images/icons/wink.gif
Anyway the statement that you can't learn C++ without learning C first is complete crap

Banjo
12-13-2001, 04:41 AM
The difference between getch and getche is that the e stands for echo. It displays the type character on screen.
Scanf requires that you press enter after you have entered your data. If is normally used for entering strings whereas
getch(e) return a single character as soon as it is pressed.

Yoda
12-13-2001, 05:42 AM
Thx for explaining !

Thinker
12-13-2001, 07:05 AM
The operators &lt;&lt; and &gt;&gt; are normally used in C for bit shifting. This is
an example of the extremes of polymorphism found in C++, operator
overloading. When defining a class, it is possible to not only have methods
and properties, it is possible to write new definitions for the standard C/C++
operators that apply when used against a member of the class. This makes
it possible for the String class to define + as a concatenation operator for
String Objects, while remaining addition for numeric variables.

reboot
12-13-2001, 07:57 AM
I'll not debate the c vs c++ thing. (c is better of course) :)
I won't even ask why you're posing this question on a visual basic forum.
What I really want to know is, why are you writing DOS programs?

orufet
12-13-2001, 08:40 AM
He's not. He's writing them in a console. It's nearly impossible to start writing a program for Windows when you don't even know the basic functions of the language you're learning.

robot313
12-13-2001, 02:03 PM
Couldn't have said it better, orufet.

reboot: Like I said, some people here seem to know about C/C++ so I'm asking here. This is a programming forum. But I'll ask my C questions in another forum from now on if you want.

reboot
12-13-2001, 02:11 PM
uh... like I said, I wasn't debating the c thing... just wondering why you're writing DOS programs.

None of my business what questions you post here.

robot313
12-13-2001, 02:18 PM
I want to. I'm just starting to learn C or C++. By the way, aren't they the same, just C++ has a little more stuff?

Banjo
12-13-2001, 02:19 PM
Console programs have their use. They are especially useful for server apps where they can be easily access over a telnet link or in a login script.

As for talking about C, we don't mind. At least your in the correct board. images/icons/smile.gif

Keltus
12-13-2001, 02:20 PM
C++ has classes. everything else is the same :)

reboot
12-13-2001, 02:29 PM
c++ has classes and a lot more keywords. c only has 32 keywords. c++ also has things like operator over-loading and etc. A book would be good.

robot313
12-14-2001, 01:34 PM
orufet, please post some more links to tutorials now. Thanks.

orufet
12-14-2001, 07:08 PM
C++ Bookmark (http://www.vb-bookmark.com/CppTutorial.html)

Beginners -- C++ Programming (http://www.gametutorials.com/Tutorials/Beginners/Cpp_Pg1.htm)

C/C++ Programming (http://www.ddj.com/topics/cpp/)

I found most of these a little while ago on Google. That's all I have in my Favs folder, but I'm sure I've got some more URLs buried in my computer somewhere...

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum