BetaArchive Logo
Navigation Home Screenshots Image Uploader Server Info FTP Servers Wiki Forum RSS Feed Rules Please Donate
UP: 25d, 21h, 31m | CPU: 29% | MEM: 5590MB of 12227MB used
{The community for beta collectors}

Forum rules


Any off topic discussions should go in this forum. Post count is not increased by posting here.
FTP Access status is required to post in this forum. Find out how to get it


Post new topic Reply to topic  [ 20 posts ] 
Author Message
 PostPost subject: Sams teach yourself CPlusPlus in 3 weeks        Posted: Thu Sep 27, 2007 4:24 pm 
Reply with quote
Donator
Offline

Joined
Wed Aug 22, 2007 8:42 am

Posts
173

Location
Manchester, UK

Favourite OS
AmigaOS3.9
I've got this now, (swedish version) well, actually borrowed from a friend (Hardcopy borrowed, not PDF copy borrowed;) and was wondering if anyone could nudge me a good compiler (_NOT_ Commercial, and _NOT_ MS VC Express ) to use with it?

It doesn't specify any compiler to be particurlarly supported by the book or otherwise. Though it does look like it's aimed at console programs firstly, I've not seen any GUI references yet from a quick scanthrough.

So would for example Borland C++ for DOS be just as good an alternative?

Oh, the book was printed in 1997, original, and translated and printed in Swedish in 1998, if that has anything todo with any decision making


Top  Profile
 PostPost subject:        Posted: Thu Sep 27, 2007 4:36 pm 
Reply with quote
Donator
Offline

Joined
Sat Aug 19, 2006 1:25 am

Posts
590

Location
Israel
GCC. Run on Cygwin if you use Windows. Get KDevelop if you want a GUI and use KDE.


Top  Profile
 PostPost subject:        Posted: Thu Sep 27, 2007 6:04 pm 
Reply with quote
Donator
Offline

Joined
Wed Aug 22, 2007 8:42 am

Posts
173

Location
Manchester, UK

Favourite OS
AmigaOS3.9
And if I want DOS? Watcom?


Top  Profile
 PostPost subject:        Posted: Thu Sep 27, 2007 6:16 pm 
Reply with quote
Donator
Offline

Joined
Sat Sep 30, 2006 5:00 pm

Posts
3557
What do you want? Do you want to compile on DOS (->Watcom, I'd say) or do you want to compile for DOS (->GCC then)?


Top  Profile
 PostPost subject:        Posted: Thu Sep 27, 2007 7:08 pm 
Reply with quote
Donator
Offline

Joined
Wed Aug 22, 2007 8:42 am

Posts
173

Location
Manchester, UK

Favourite OS
AmigaOS3.9
Well... on and for, I guess..... I just think, installing a Linux distro or getting CygWin to work is a little much for just the basic "learn how to code." I kinda want to sort of learn the DOS thing first (really basic and unconfusing when it comes down to it) then build up to a GUI environment like X or Windows or whatever later on as I build my confidence and such up, if that makes sense.

Besides... I've tried to look at the Windows and KDE developement packs and they REALLY puts me off from coding anything at all :/


Top  Profile
 PostPost subject:        Posted: Sat Sep 29, 2007 11:35 pm 
Reply with quote
Donator
Offline

Joined
Tue Oct 17, 2006 8:26 pm

Posts
930
DJGPP is a DOS port of GCC.


Top  Profile
 PostPost subject:        Posted: Sun Sep 30, 2007 2:18 am 
Reply with quote
Permanently Banned
Offline

Joined
Mon Dec 11, 2006 3:09 am

Posts
463
DJGPP or MinGW (for DOS/Win32).


Top  Profile
 PostPost subject:        Posted: Thu Oct 04, 2007 3:51 am 
Reply with quote
Donator
Offline

Joined
Wed Aug 22, 2007 8:42 am

Posts
173

Location
Manchester, UK

Favourite OS
AmigaOS3.9
Well, I've found out ONE thing at least:

VisualC++ is NOT for beginners. I can't figure out even how to compile the "Hello World" program.

Probably nice for Windows applications and bigger things, but for a complete beginner, VC++ 2005 is like putting a 5yo behindthe wheel of a Ferrari F40 and expect him to drive like a pro :(


Top  Profile
 PostPost subject:        Posted: Mon Oct 08, 2007 6:03 am 
Reply with quote
Donator
Offline

Joined
Wed Aug 22, 2007 8:42 am

Posts
173

Location
Manchester, UK

Favourite OS
AmigaOS3.9
How do I read .h files?

For example, iostream.h is needed to get the line

cout >> "Hello, World!\n";

to actually print the text "Hello World!" to the console, right?

But if I open iostream.h all I see is definitions and EQU's, I don't see how the cout function is defined and atemplate of the functions' ptional components.

So how how do I read them?


Top  Profile
 PostPost subject:        Posted: Mon Oct 08, 2007 12:01 pm 
Reply with quote
Donator
Offline

Joined
Sat Aug 19, 2006 1:25 am

Posts
590

Location
Israel
You include them using a #include directive, for example:
Code:
#include <iostream.h>

int main(void)
{
   cout << "Hello, World!" << endl;
   return 0;
}

The < and > characters tell the compiler to search for the file in the standard header directory (on UNIX in /usr/include, on DOS/Windows it depends on the compiler). If you want to include your own header file (which resides in the same directory as the rest of your code), use standard quotes (e.g. #include "myheader.h").

BTW, cout isn't a function. It's a predefined instance of the ostream class, which overloads the << operator (so << is actually a function of the ostream class).


Top  Profile
 PostPost subject:        Posted: Mon Oct 08, 2007 2:44 pm 
Reply with quote
Donator
Offline

Joined
Wed Aug 22, 2007 8:42 am

Posts
173

Location
Manchester, UK

Favourite OS
AmigaOS3.9
Yes, I know that... but HOW do I read them?

To use the C one instead...
Code:
#include stdio.h

void main()
{
   printf("Hello, World!\n");
   return 0;
}

I'm certain the code isn't 100% but it serves my purpose:

To use the printf()-function, I needed stdio.h to be included first.
But in stdio.h, there's absolutely NO REFERENCE to printf()

Which is what I'm asking about..... I know it's there, but I have no clue as to HOW to make sense from the .h files.

Say, if I wanted to make a simple GUI to go on top of FreeDOS (just a very very basic one, let's you open a directory as a window, and a file in the directory could be executed, for example) I would need to make an API and include-files myself, right?

Not easy when I don't understand HOW it functions, only that it does. I want to know the HOW ;)


Top  Profile
 PostPost subject:        Posted: Wed Oct 10, 2007 9:20 pm 
Reply with quote
Permanently Banned
Offline

Joined
Mon Dec 11, 2006 3:09 am

Posts
463
first off, returning 0 in a void will do nothing. 0 is an int, you need to declare the function as an integer

http://www.zimmy.ca/pub/cpp/app1 <- compiled cpp version of that code you posted, with comments

http://www.zimmy.ca/pub/cpp/app2 <- very very basic classes (cpp and h files). Shows a bit of defining, and usage. Commented.

.H files are only for classes. Most apps are not just a single .cpp file but are composed of many classes that serve different functions. Look at the code.


Top  Profile
 PostPost subject:        Posted: Thu Oct 11, 2007 4:01 am 
Reply with quote
Donator
Offline

Joined
Wed Aug 22, 2007 8:42 am

Posts
173

Location
Manchester, UK

Favourite OS
AmigaOS3.9
It's NOT AT ALL what I'm asking about.

I'm asking about how to extract information FORM a .h file.....

in the case of the printf()-function, I know there's escape-sequences that can be added in there.... like \n for newline and so on.

What I'm asking is: "How do I read stdio.h (for example) to get the programming information about optional components to use in a function?"

If you read my previous code carefully, you'll see that the correctness about the posted code wasn't the issue, the issue is about I've no idea HOW STDIO.H WORKS.

I know I need to #include stdio.h to use printf(), but when I open stdio.h, there's no reference whatsoever to the function.


Top  Profile
 PostPost subject:        Posted: Thu Oct 11, 2007 8:24 am 
Reply with quote
Permanently Banned
Offline

Joined
Mon Dec 11, 2006 3:09 am

Posts
463
Doctor Mindvipe wrote:
It's NOT AT ALL what I'm asking about.

I'm asking about how to extract information FORM a .h file.....

in the case of the printf()-function, I know there's escape-sequences that can be added in there.... like \n for newline and so on.

What I'm asking is: "How do I read stdio.h (for example) to get the programming information about optional components to use in a function?"

If you read my previous code carefully, you'll see that the correctness about the posted code wasn't the issue, the issue is about I've no idea HOW STDIO.H WORKS.

I know I need to #include stdio.h to use printf(), but when I open stdio.h, there's no reference whatsoever to the function.


The caps lock key is 1/16'th of an inch from the A key. Feel free to avoid that key.

Anyway, it may not be present in stdio, but in any of the include files (h files) it inherits. Feel free to look around in all of them.

Oh, and try and be less rude to people who help out. I had the wrong impression.


Top  Profile
 PostPost subject:        Posted: Thu Oct 11, 2007 11:07 am 
Reply with quote
Donator
Offline

Joined
Wed Aug 22, 2007 8:42 am

Posts
173

Location
Manchester, UK

Favourite OS
AmigaOS3.9
Sorry if I came across as rude... I'm just frustrated with the whole .h thing.....

All I see in any .h files, are define this and define that, such EQU so and so EQU such.

To my best ability, I'm unable to understand excactly WHAT I'm looking at when trying to get information about an #include'd .h about the functions() it's supposed to give me access to.

Say... if I omit "#include stdio.h" in the hello world example, the compiler will throw up an error when it comes to the line "printf("hello world"\n)" right?

So I know I need to include the stdio for printf() to work. And it's also very logical (at least inside my head) to have a look at stdio.h to see how the printf() function works, and also to get more information about the optional components said function may or may not allow for.

But no.... there's nothing of any logical sense whatsoever for me inthe .h files. And if I don't really understand waht I'm looking at I rather put my learning on hold untill I get my question answered.

*sigh*

C is such a screwedup language when you don't know the bits and back of thing you need/want to undersatnd


Top  Profile
 PostPost subject:        Posted: Fri Oct 12, 2007 10:53 am 
Reply with quote
Donator
Offline

Joined
Sat Aug 19, 2006 1:25 am

Posts
590

Location
Israel
Zimmy wrote:
.H files are only for classes.

Actually, they're for all sorts of declarations (if they were only for classes, what do they do in plain C, which has no classes?). Constants, functions, types, structures, and classes go into .h files.

Doctor Mindvipe wrote:
C is such a screwedup language when you don't know the bits and back of thing you need/want to undersatnd

.h files don't contain any code, they just contain declarations that help the compiler know what it's dealing with. The actual printf() function resides in some object file or shared library (e.g. libc.so or msvcrt.dll), while the header file tells the compiler how to call it.

You usually don't need to read header files, especially the standard ones. You can find reference to all standard C and C++ functions here.


Top  Profile
 PostPost subject:        Posted: Fri Oct 12, 2007 3:16 pm 
Reply with quote
Donator
Offline

Joined
Wed Aug 22, 2007 8:42 am

Posts
173

Location
Manchester, UK

Favourite OS
AmigaOS3.9
Thanks, PPC :D

if I look at this printf() explanation..... is the "Specifier" field all the diffferent \-sequences that can be used? As in, \d, \n, \f and so on?

You'ld think it was natural to look into the file specified to be included, to get info about the functions that file "unlocks" wouldn't you? (for example printf() in the stdio.h for C)


Top  Profile
 PostPost subject:        Posted: Fri Oct 12, 2007 8:44 pm 
Reply with quote
FTP Access
User avatar
Offline

Joined
Fri Sep 01, 2006 10:04 pm

Posts
1022

Location
The Ephemeral between existance and non-existance: AKA "being"

Favourite OS
Rhapsody, BeOS
printf(), if I remember correctly is a surprisingly complicated function because it handels all types of data...

Something from the ostream maybe easier to understand like cout:: ie
Code:
cout << "Text"

because DOS was a console system...

My first experience with printf() was when I started Windows programing :)

_________________
Image
Part Time Troll - HPC Enthusiast - Spelling Master - Old Fart


Top  Profile  WWW
 PostPost subject:        Posted: Sat Oct 13, 2007 5:00 am 
Reply with quote
Donator
Offline

Joined
Wed Aug 22, 2007 8:42 am

Posts
173

Location
Manchester, UK

Favourite OS
AmigaOS3.9
:cries

I'm sure 99% of you guys are either Politicians, Lawyers, or MicroSoft Employees.

Frozenport:

A simple "yes" or "no" would have sufficed.... I provided even a link to the explanation of the particular function, so why bring cout into this? I simply want to understand what I'm looking at and reading....... and if I'm looking at the explanation for printf, I don't see what good it will do me to bring out cout, as the explanation for cout will only bring me back to my question:

is the "Specifier" field all the diffferent \-sequences that can be used? As in, \d, \n, \f and so on?

you see what I mean?


Top  Profile
 PostPost subject:        Posted: Sat Oct 13, 2007 8:02 pm 
Reply with quote
Donator
Offline

Joined
Sat Aug 19, 2006 1:25 am

Posts
590

Location
Israel
Doctor Mindvipe wrote:
is the "Specifier" field all the diffferent \-sequences that can be used? As in, \d, \n, \f and so on?

The specifier field is where you put the type of the value you're including. %d (i.e. 'd' is the specifier) means signed decimal, while %c ('c' is the specifier) represents a character. The escape sequences (e.g. \n and \r) can be used in any string, not just in printf(). They're processed by the compiler at compile time (so your \n will be replaced with a 0x0A byte on the final executable).

@frozenport: What does printf() have to do with Windows? It deals with console output, just like cout. cout was intended to replace printf() in C++. I (and many other C developers) prefer printf() over cout, as it makes code easier to read later on (and a lot faster).


Top  Profile
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 20 posts ] 




Who is online

Users browsing this forum: No registered users and 5 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Jump to:  

All views expressed in these forums are those of the author and do not necessarily represent the views of the BetaArchive site owner.

Powered by phpBB® Forum Software © phpBB Group

Copyright © 2006-2018

 

Sitemap | XML | RSS