Thread: Can some one please help!!!!!

  1. #1
    Registered User JasonShadow's Avatar
    Join Date
    Jun 2011
    Location
    Norwich, England
    Posts
    3

    Can some one please help!!!!!

    Im new to c++ ive installed code blocks compiler and completed the hello world prog and varables section so I thought I would try other progs from online from c++ programming site to get an understanding of c++ but every prog I try all I get is different errors for every line, this are the sort of errors
    from the compiler on virtually every prog I try:

    C:\Users\Jason\Programming\Code\main.cpp|1|error: iostream.h: No such file or directory|
    C:\Users\Jason\Programming\Code\main.cpp|4|error: '::main' must return 'int'|
    C:\Users\Jason\Programming\Code\main.cpp||In function 'int main()':|
    C:\Users\Jason\Programming\Code\main.cpp|6|error: 'clrscr' was not declared in this scope|
    C:\Users\Jason\Programming\Code\main.cpp|8|error: 'cout' was not declared in this scope|
    C:\Users\Jason\Programming\Code\main.cpp|8|error: 'endl' was not declared in this scope|
    C:\Users\Jason\Programming\Code\main.cpp|9|error: 'cin' was not declared in this scope|
    ||=== Build finished: 6 errors, 0 warnings ===|


    Every day I try to do a little and learn some thing new but every day Im feeling like giving up because I get this from the compiler. What is the not "declared in this scope" is my compiler not configured correctly. Ive gone through the setup guide on this site and followed it exactly. Please help!!!!!

  2. #2
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    28,413
    Unfortunately, many tutorials out there, possibly including some of the old ones on this website, are outdated or plain wrong. I suggest that you work through a book like Accelerated C++.
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  3. #3
    Registered User
    Join Date
    May 2010
    Posts
    4,633
    C:\Users\Jason\Programming\Code\main.cpp|1|error: iostream.h: No such file or directory|
    This is in old pre-standard header that is not available any longer the correct replaced by
    Code:
    #include <iostream>
    Note the missing file extension.
    C:\Users\Jason\Programming\Code\main.cpp|4|error: '::main' must return 'int'|
    In a C++ program main function must be defined to return an int
    Code:
    int main()
    C:\Users\Jason\Programming\Code\main.cpp|6|error: 'clrscr' was not declared in this scope|
    The function clrscr() is not a standard function an is probably not available with your compiler. To fix this error delete all calls to this function.
    C:\Users\Jason\Programming\Code\main.cpp|8|error: 'cout' was not declared in this scope|
    C:\Users\Jason\Programming\Code\main.cpp|8|error: 'endl' was not declared in this scope|
    C:\Users\Jason\Programming\Code\main.cpp|9|error: 'cin' was not declared in this scope|
    These errors are because you are not properly scoping functions in the standard namespace. To fix these errors you will either need to use the scope resolution operator (:: ) in front of each call to these functions (std::cout) or by the using namespace std; declaration prior to your main function.

    Jim

  4. #4
    spurious conceit MK27's Avatar
    Join Date
    Jul 2008
    Location
    segmentation fault
    Posts
    8,300
    Quote Originally Posted by laserlight View Post
    Unfortunately, many tutorials out there, possibly including some of the old ones on this website, are outdated or plain wrong.
    The stuff here seems to be more consistent/up to date:

    C++ Language Tutorial - C++ Documentation

    Altho there is nothing about compiling there, it does say the code should work with any C++ compiler.

    I'm sure it's frustrating at first if you are new to programming. Hang in there and don't be afraid to ask questions.
    Last edited by MK27; 06-28-2011 at 08:00 AM.
    C programming resources:
    GNU C Function and Macro Index -- glibc reference manual
    The C Book -- nice online learner guide
    Current ISO draft standard
    CCAN -- new CPAN like open source library repository
    3 (different) GNU debugger tutorials: #1 -- #2 -- #3
    cpwiki -- our wiki on sourceforge

  5. #5
    Registered User JasonShadow's Avatar
    Join Date
    Jun 2011
    Location
    Norwich, England
    Posts
    3
    Thank you lazerlight, You are one pretty programmer!! and every one who has posted you are a real help.
    Last edited by JasonShadow; 06-28-2011 at 08:45 AM.

  6. #6
    Registered User JasonShadow's Avatar
    Join Date
    Jun 2011
    Location
    Norwich, England
    Posts
    3
    Thank you, you are one pretty programmer!!
    Quote Originally Posted by laserlight View Post
    Unfortunately, many tutorials out there, possibly including some of the old ones on this website, are outdated or plain wrong. I suggest that you work through a book like Accelerated C++.

  7. #7
    spaghetticode
    Guest
    One additional advice which is off-topic only at first sight and which is not at all meant as an offence: Try to work on the way you're writing. Grammar rules also apply to posting on the internet. Use punctuation, spell out your words instead of using sms speak, use paragraphs, think about what you want to say and how to express that before-hand.

    Programming languages *need* strict grammar rules, because your CPU's capabilities of interpretation are very limited. If you can't even put enough effort to express yourself properly in a natural language, you will never learn a programming language to a high extend.

Popular pages Recent additions subscribe to a feed