Okey , this is what happends , when I write in my code and compile it this error shows up. http://data.fuskbugg.se/dipdip/Problem%20med%20c%2B%2B%20script.jpg

And after recieving this error I can't run it ofcourse... , I got the code from a book " Learn c++ in 3 weeks" I copied the code and watched if I made something wrong 100 times but I keep getting errors , here's the code.

// Lista 2.2 - använda cout
#inculde <iostream.h>
int main()
{
    cout << "Hallå där.\n";
    cout << "Här är 5: " << 5 << "\n";
    cout << "endl lägger in en ny rad på skärmen.";
    cout << endl;
    cout << "Här kommer ett stort tal:\t" << 70000 << endl;
    cout << "Summan av 8 och 5 är:\t" << 8+5 << endl;
    cout << "Här kommer ett bråktal:\t\" << (float) 5/8 << endl;
    cout << "Och här kommer ett väldigt, väldigt stor tal:\t";
    cout << (double) 7000 * 7000 << endl;
    cout << "Jag är en c++ programmerare!\n";
    system("PAUSE");
    return 0;
}

Sorry for the swedish language, but what the hell do I do wrong? , one more thing I opened the project as console project it should be? cause it's opening <iostream.h> ? Well I have no Idea. I allso tryed compiling it in both visual c++ 2010 and dev-c++. Please help :/!

Recommended Answers

All 7 Replies

First of all get some better c++ book, as I can see it is not very modern (iostream.h was deprecated a long time ago and now using it is an error).
But in this example you just made spelling error with include directive.

First of all get some better c++ book, as I can see it is not very modern (iostream.h was deprecated a long time ago and now using it is an error).
But in this example you just made spelling error with include directive.

Ahh , thanks , yeah ... I'm using a book from 2000 and I don't have any money to buy a new one at the moment , and i just felt like I wanted to start scripting before starting school so I know some basics in the lanugage. And allso there's other guys out there but all is on english and it's a very advanced language so i don't learn anything from them , I learned HTML by a english guide but c++ is more complicated IMO :/

Well thanks for the help anyways :)

@Zjarek:
Actually, there is a problem on Line 11 also. Did you notice how the syntax highlighting changes on that line? The OP has escaped the closing double-quote in the string literal. This has messed up the pairings of the remaining double-quotes thus messing up the interpretations of the various keywords and operators after that point.


@OP:
Give it time. You can't expect to learn everything overnight.

The core structure and syntax of C++ is pretty simple. The difficult part is the libraries.

Maybe this tutorial will help. It's in english, but it's fairly easy to follow.

@Zjarek:
Actually there is a problem on Line 11 also. Did you notice how the syntax highlighting changes on that line? The OP has escaped the closing double-quote in the string literal. This has messed up the pairings of the remaining double-quotes thus messing up the interpretations of the various keywords and operators after that point.


@OP:
Actually, the core structure and syntax of C++ is pretty simple. The difficult part is the libraries.

Maybe this tutorial will help. It's in english, but it's fairly easy to follow.

Okey , I'll try it out , Thanks :) , I'll reply back to you if the guide was good :)

@Zjarek:
Actually, there is a problem on Line 11 also. Did you notice how the syntax highlighting changes on that line? The OP has escaped the closing double-quote in the string literal. This has messed up the pairings of the remaining double-quotes thus messing up the interpretations of the various keywords and operators after that point.


@OP:
Give it time. You can't expect to learn everything overnight.

The core structure and syntax of C++ is pretty simple. The difficult part is the libraries.

Maybe this tutorial will help. It's in english, but it's fairly easy to follow.

I tryed out the tutorial and I finished 2 chapters for to day , hmm.. I think I got most of it but if I don't get some stuff like why I have to put the return 0; and if I can't do a string program , or a hello world program after reading it should I read it again untill I can make this program on my own without looking at it? , and allso how much of the c++ should I put in my head , I guess too much studiyng is bad , I'll prolly forget most of the stuff so yeah , that's what I wanted to ask you , for how long should I study , maybe 2 chapters or so? , and do I have to know how to make a program like they do in the tutorial before I continue , or am I going to get that stuff when I get further into the tutorial , Thanks in forehand !

You arent actually required to return anything in console applications, the program returns 0 anyways, but it is good practice to put it there. Your goal should be to follow all good practices that you find and understand where they should be used. The return value is used when an error occures to notify your operation system. Its not a big problem if you do not return anything in the end of the program. But its important on the other hand to understand how you can return values for function calls etc.

My experience with C++ is that the more programs i write the better i get at it. I had problems too, like you are having now, memoryizing every keyword etc, do not worry, it will get better the more you write.

Try not to push forward too hard, rather focus on writing applications and understanding the tutorial in hand. Think about it this way, the less you skip, the less you have to work afterwards to understand the more interesting (and useful) things. But dont get stuck either, C++ is very dynamic in sense that it can cater your needs, but you need to figure out what your needs are and how C++ can help you fulfill them. There are many ways to go, but chances are only few of them you should take.

I tryed out the tutorial and I finished 2 chapters for to day , hmm.. I think I got most of it but if I don't get some stuff like why I have to put the return 0; and if I can't do a string program , or a hello world program after reading it should I read it again untill I can make this program on my own without looking at it? , and allso how much of the c++ should I put in my head , I guess too much studiyng is bad , I'll prolly forget most of the stuff so yeah , that's what I wanted to ask you , for how long should I study , maybe 2 chapters or so? , and do I have to know how to make a program like they do in the tutorial before I continue , or am I going to get that stuff when I get further into the tutorial , Thanks in forehand !

After reading that much, you should understand that every program requires a main() function and start to recognize some basic structural conventions. You should also be able to recognize the 2 different comment types.

main() is required to return a zero (0) value to the operating system to indicate that the program ran properly and exited with no errors. A return value other than (0) would indicate an error causing abnormal program termination. This is clearly defined in the ISO standard for C++. The main() must return an int, and (0) indicates no errors were generated.

Don't try to cram. Just like anything else, it's all repetition. As you do it more, and read farther into the tutorial, you will begin to understand the structure better and things will start to become "automatic" for you. There is a lot of stuff that you have to figure out all at once to get started, but once you do, you won't think anything of it. It will become second nature. Once the basics start taking less thought, you can start looking at other parts of the Standard C++ libraries and functionalities.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.