Thread: Error not declared in this scope

  1. #1
    Registered User
    Join Date
    Feb 2012
    Posts
    2

    Error not declared in this scope

    I am trying to practice my programming skills by writing a program to mess around with my friends in class. But I am having some trouble doing it.
    Here is what I wrote and the error I am receiving.
    Error not declared in this scope-csi-png

  2. #2
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    28,413
    You need to quote the string literal, i.e., "michael" not michael. Also, the correct header for std::string is <string>, not <cstring>. <cstring> is for functions - inherited from C - that work with null terminated strings. You should explicitly declare main as returning an int.
    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
    Feb 2012
    Posts
    2
    Man that was obvious. I have a lot to learn. But thank you for answering my question.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Not declared in this scope Error, Templates
    By gbman88 in forum C++ Programming
    Replies: 13
    Last Post: 01-19-2011, 06:40 PM
  2. error: ‘futex’ was not declared in this scope
    By crazyinlove in forum Linux Programming
    Replies: 4
    Last Post: 12-20-2010, 05:59 PM
  3. error PATH_MAX was not declared in this scope
    By kiros88 in forum C++ Programming
    Replies: 2
    Last Post: 04-02-2010, 06:36 PM
  4. xy was not declared in this scope: compiler error!
    By twilight in forum C++ Programming
    Replies: 41
    Last Post: 08-13-2009, 12:33 PM
  5. Replies: 2
    Last Post: 02-12-2005, 06:50 PM