Public Group

Archived

This topic is now archived and is closed to further replies.

Newbies and Beginner Programmers come!

This topic is 5477 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

Recommended Posts

Hello, I just thought that I would create basic C++ tutorials through examples to help people out. Now, what I will do is send out the source to people who ask. So far I've gotten 2 samples going. The first one is: Chapter 1 - Strings and Basics The second one is: Chapter 2 - If and While Loops and Basics The code is fully commented to help the user understand what's going on. Well, here's the code from chapter 1 to give you guys a basic idea of what it's like.
// This program just gets the user to input something and displays

// it back with a little border.

#include <iostream>
#include <string>

using namespace std;

int main()
{
cout << "Welcome to the test program using strings" << endl;
cout << "Enter a one word text" << endl;

// Creates a string that grabs their text

string text;
cin >> text;

// Grabs length of text and declares border size and text

const string Length("You entered " + text + " as your text");
const string Border(Length.size(), '*');

// Prints border with message

cout << Border << endl;
cout << Length << endl;
cout << Border << endl;
cout << "\tPress Enter to Continue " << endl;

// So the console doesn't disappear

cin.ignore();
cin.get();
return 0;
}

I will be finishing each Chapter daily. So every day a new Chapter is out :D. If you have any questions don't hesitate to post back... I'm just trying to help those diving into C++ [edited by - ThomasSauder on September 24, 2003 6:29:48 PM]

Share on other sites
Why doesn''t your code work on dev-c++ IDE. I had six errors when I tried to compile, and I''m sure that I write it correctly (I copy and paste it in).

I''ve gotten some books on C++, I try to do the exercises but the code never compiles. What''s wrong.

Thanks

Jakoozie

Share on other sites
I''m actually using DevC++... What are the errors you''re getting?

Share on other sites
I get errors like:cout undeclared(first use this function)
and:"Each undeclared identifier is reported only one for each" and:endlundecleared (first use this function) and: "parse error at end of input" and: "No such file or directory".

What does it mean?(explain simply, i''m a noob.
thanks

Jakoozie

Share on other sites
I think it means that you didn''t include the iostream file correctly or you''re not using a std namespace. It worked correctly in mine and I''m using Dev-C++.

Share on other sites
If that source is thought to be a tutorial you should imho do a lot more commenting.
For example: What is #include?. What is cout? What is a string? Those answers don´t need to be scientifically exact ("a string is a variable that stores texts" is enough) but should give the newb rough overview.

Share on other sites
It isn''t meant for someone that has never touched a programming language before... It''s for someone who knows the basics... like, basically just a few if the i/o commands...

If people would want me to add a tutorial page for completely new people, then I will, they just need to ask

Cheers

Share on other sites
try typing iostream.h etc and losing using namespace std...

Share on other sites
quote:

try typing iostream.h etc

No! No! No!

quote:

and losing using namespace std...

It''s fine for an introductory sample.

Share on other sites
Okay, I''m not quite a beginner with programming, however I''ve come across some old things that I seem not to have learned. First of all I have no idea what a "enum" is. A program I''m trying to understand has them all over the place. Can anyone explain to me how to use these?

1. 1
2. 2
3. 3
Rutin
18
4. 4
JoeJ
14
5. 5

• 14
• 10
• 23
• 9
• 32
• Forum Statistics

• Total Topics
632632
• Total Posts
3007524
• Who's Online (See full list)

There are no registered users currently online

×