Thread: Chars

  1. #1
    . Driveway's Avatar
    Join Date
    May 2002
    Posts
    469

    Chars

    I have a problem. I isolated it to two lines.

    Code:
    char *aMenuChoice;
    cin>>aMenuChoice;
    My problem, a runtime error. It is- The variable 'aMenuChoice' is being used without being defined.

    And we know it is.

    and then later I get this when I enter something and hit the key enter:
    Unhandled exception at 0x0041441f in Classes.exe: 0xC0000005: Access violation writing location 0xcccccccc.

    What's my problem?

  2. #2
    Banned borko_b's Avatar
    Join Date
    Jun 2002
    Location
    Well... I live in Bulgaria :)
    Posts
    100
    your variable is declared as a pointer
    and it is pointing to un-allocated memory...

    this is the thing that crashes your program

    it must be either

    char choise;
    cin>>choise;

    OR
    char *choise = new char[200];//string
    cin>> choise; //assign something to the string

  3. #3
    . Driveway's Avatar
    Join Date
    May 2002
    Posts
    469
    Never mind, I got it

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. while condition question..
    By transgalactic2 in forum C Programming
    Replies: 3
    Last Post: 04-04-2009, 04:49 PM
  2. Counting how many chars in a string
    By tigs in forum C Programming
    Replies: 4
    Last Post: 08-05-2002, 12:25 AM
  3. really got stuck with unsigned chars
    By Abdi in forum C Programming
    Replies: 7
    Last Post: 06-11-2002, 12:47 PM
  4. move chars position
    By SpuRky in forum C Programming
    Replies: 3
    Last Post: 06-09-2002, 02:59 AM
  5. fancy strcpy
    By heat511 in forum C++ Programming
    Replies: 34
    Last Post: 05-01-2002, 04:29 PM