Thread: Switch/case problem with file I/O

  1. #1
    Registered User
    Join Date
    May 2005
    Posts
    12

    Switch/case problem with file I/O

    Hello, i'm trying to take the tutorial of switch/ case and add file IO. I've gotten something to this effect but everytime i try to input the file it says that the variables I have aren't declared when i clearly defined my char variables under int input. if you want the code to see what is wrong please tell me and i'll e-mail cause i don't know how to do the code tags and the link doesn't work


    errors:

    --------------------Configuration: switch_case - Win32 Debug--------------------
    Compiling...
    switch_case.cpp
    C:\Program Files\Microsoft Visual Studio\MyProjects\switch_case\switch_case.cpp(14) : warning C4101: 'space' : unreferenced local variable
    C:\Program Files\Microsoft Visual Studio\MyProjects\switch_case\switch_case.cpp(66) : error C2065: 'space' : undeclared identifier
    Error executing cl.exe.

    switch_case.exe - 1 error(s), 1 warning(s)

  2. #2
    Registered User
    Join Date
    Jan 2005
    Posts
    847
    you can use code tags by placing a [ code ] without the spaces before your code and a [ / code ] without the spaces at the end of your code.
    From the error messages it looks like your variable has become out of scope.
    If you have something like this
    Code:
    {
       int MyVariable=0;
       
    }
    MyVariable++;
    The last line would produce an error because MyVariable is only valid inside the braces it was declared in.

  3. #3
    Registered User
    Join Date
    May 2005
    Posts
    12
    I figured out that i needed to declare that variable within that function that handled the particular operation. Thanks for ur help

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Need Help Fixing My C Program. Deals with File I/O
    By Matus in forum C Programming
    Replies: 7
    Last Post: 04-29-2008, 07:51 PM
  2. File i/o problem
    By tezcatlipooca in forum C++ Programming
    Replies: 18
    Last Post: 01-01-2007, 09:01 AM
  3. File I/O problem
    By Onions in forum C++ Programming
    Replies: 41
    Last Post: 02-24-2006, 04:32 PM
  4. File I/O problem
    By 81N4RY_DR460N in forum C++ Programming
    Replies: 12
    Last Post: 09-03-2005, 12:14 PM
  5. Possible circular definition with singleton objects
    By techrolla in forum C++ Programming
    Replies: 3
    Last Post: 12-26-2004, 10:46 AM