Thread: visual c++ isnt likng my varibale

  1. #1
    Sir Mister Insane Sako Klinerr1's Avatar
    Join Date
    May 2002
    Posts
    608

    visual c++ isnt likng my varibale

    string location;

    that is line 24 and i get these errors

    C:\My Documents\Vcpp\Coder Utensil\main.cpp(24) : error C2146: syntax error : missing ';' before identifier 'location'
    C:\My Documents\Vcpp\Coder Utensil\main.cpp(24) : error

    what logic is it not liking string?
    Email: [email protected] || AIM: MisterSako || MSN: [email protected]

    -the shroom has spoken

  2. #2
    I lurk
    Join Date
    Aug 2002
    Posts
    1,361
    Post your code..
    Although it sounds like you have the wrong include file.

  3. #3
    Sir Mister Insane Sako Klinerr1's Avatar
    Join Date
    May 2002
    Posts
    608
    Code:
    #include <stdlib.h>
    #include <iostream>
    #include <string>
    #include <fstream>
    #include <stdio.h>
    #include <conio.h>
    #include <windows.h>
    
    #define ofstream fout;
    #define ifstream fin;
    
    void title();
    void menu();
    void organizecode();
    void searchcode();
    void addcode();
    void addcode_directory();
    void addcode_code();
    void info();
    
    int input;
    
    string location[] = "";
    
    using namespace std;
    
    int main()
    {
        menu(); 
    }
    
    void menu()
    {
    	title();
    	cout << "     What operation would you like to do?" << endl;
    	cout << endl;
    	cout << "1. Organize Code" << endl;
    	cout << "2. Search Code" << endl;
    	cout << "3. Add Code" << endl;
    	cout << "4. Information" << endl;
    	cout << "5. Exit" << endl;
    	cout << endl;
    	cin >> input;
        switch(input)
    	{
    		case 1: organizecode();
    			  break;
    
            case 2: searchcode();
         		  break;
    
            case 3: addcode();
    			  break;
    
            case 4: info();
    			  break;
    
            default: exit(0);
    			  break;
      }	
    }
    
    void organizecode()
    {
    	title();
        cout << "     Where is the code located?" << endl;
    	cin >> location;
    
    }
    
    void searchcode()
    {
    	title();
        cout << "     What Directory is the Code in?" << endl;
    	//change directory to directory and the do a system dir
    
    }
    
    void addcode()
    {
    	title();
        cout << "     Add a directory or code?" << endl;
    	cin >> input;
        switch(input)
    	{
    		case 1: addcode_directory();
    			  break;
    
            case 2: addcode_code();
         		  break;
    
            default: 
    			cout << "Invalid Input...";
    			Sleep(3000);
    			menu();
    			  break;
      }	
    
    }
    
    void addcode_directory()
    {
    	title();
    // add directory
    	
    }
    void addcode_code()
    {
    	title();
    //add code
    }
    
    
    void info()
    {
    	title();
        cout << "Writtin By: Daniel Strong" << endl;
    	cout << "  http://vc.flashstyle.org" << endl;
        cout << "    [email protected]" << endl;
        cout << endl;
    	//add info on using the program
    	cout << endl;
    	system("pause");
    	menu();
    }
    
     
    void title()
    {
    	system("cls");
    	cout << "--------------------------------------------------------------------------------" << endl;
    	cout << "               ____      __         __        ____   _____   _____   ____ " << endl;
        cout << "              |  __|    |  |       |  |      |  __| |  _  | |  _  | |  __|" << endl;
        cout << "              | |     __|  |__   __|  |__    | |    | | | | | | | | | |__ " << endl;
    	cout << "              | |    |__    __| |__    __|   | |    | | | | | | | | |  __|" << endl;
    	cout << "              | |__     |  |       |  |      | |__  | |_| | | |_| | | |__ " << endl;
    	cout << "              |____|    |__|       |__|      |____| |_____| |_____/ |____|" << endl;
    	cout << "	                               O R G A N I Z E R" << endl;
    	cout << "		                              V1.0" << endl;
    	cout << "--------------------------------------------------------------------------------" << endl;
    	cout << endl;
    }
    yes i finally started to indent my code

    why dont u use ur old name ( duel catfish )
    Last edited by Klinerr1; 10-12-2002 at 10:12 PM.
    Email: [email protected] || AIM: MisterSako || MSN: [email protected]

    -the shroom has spoken

  4. #4
    I lurk
    Join Date
    Aug 2002
    Posts
    1,361
    > string location[] = "";

    This isn't how you using the string class
    Try string location = "";

  5. #5
    Sir Mister Insane Sako Klinerr1's Avatar
    Join Date
    May 2002
    Posts
    608
    i tried without the [] before, it amde no differ
    Email: [email protected] || AIM: MisterSako || MSN: [email protected]

    -the shroom has spoken

  6. #6
    I lurk
    Join Date
    Aug 2002
    Posts
    1,361
    string location[] = "";

    using namespace std;


    Might want to try reversing those.

    using namespace std;

    string location[] = "";

  7. #7
    Sir Mister Insane Sako Klinerr1's Avatar
    Join Date
    May 2002
    Posts
    608
    thanks, yeha i guess i shoulda relaised i didnt put namespace before string.
    Last edited by Klinerr1; 10-12-2002 at 10:32 PM.
    Email: [email protected] || AIM: MisterSako || MSN: [email protected]

    -the shroom has spoken

  8. #8
    Seeking motivation... endo's Avatar
    Join Date
    May 2002
    Posts
    537
    Code:
    #define ofstream fout;
    #define ifstream fin;
    preprocessor directives dont end with a semi-colon;
    Couldn't think of anything interesting, cool or funny - sorry.

  9. #9
    Emotionally Unstable DarkViper's Avatar
    Join Date
    Oct 2002
    Posts
    343
    MSVC++ just sucks nonetheless. their J++ compiler is good though. but a program that would have worked on Bloodshed Dev C++ and worked, didn;t work on MSVC++. so i just gave up on MSVC++ and i just use MSVJ++ only from nnow on.

    get bloodshed. its the best.
    ~DJ DarkViper signing out
    ----------------------------------------
    My Site:
    Black Jaguar Studios

    Languages:
    Fluent English, Starter German, HTML, Javascript, Actionscript, Intermediate PHP

    Verteran Despiser of: ASP, Java, BASIC, Pascal, Cobalt

  10. #10
    S Sang-drax's Avatar
    Join Date
    May 2002
    Location
    Göteborg, Sweden
    Posts
    2,072
    but a program that would have worked on Bloodshed Dev C++ and worked, didn;t work on MSVC++.
    I think Dev C++ is quite crappy, compared to compilers that cost money.
    I had code that worked in VC++, Borland C++ Builder and CodeWarrior, when I tried to compile in Bloodshed Dev C++, I got hundreds of errors. I'm quite sure that the code was ISO C++.
    #define ofstream fout;
    not recommended.
    Last edited by Sang-drax : Tomorrow at 02:21 AM. Reason: Time travelling

  11. #11
    I lurk
    Join Date
    Aug 2002
    Posts
    1,361
    Might I point out that Bloodshed Dev C++ is not a compiler.

  12. #12
    S Sang-drax's Avatar
    Join Date
    May 2002
    Location
    Göteborg, Sweden
    Posts
    2,072
    Yea, yea, I know.

    But it is usually referred to as a compiler, although it is only a GUI/IDE. I was using mingw when I tested it.
    Last edited by Sang-drax : Tomorrow at 02:21 AM. Reason: Time travelling

  13. #13
    Registered User moi's Avatar
    Join Date
    Jul 2002
    Posts
    946
    Originally posted by endo
    Code:
    #define ofstream fout;
    #define ifstream fin;
    preprocessor directives dont end with a semi-colon;
    says who? although its generally considered bad practice, they can end with whatever you want them to; the preprocessor merely does a dumb search and replace wherever it needs to.
    hello, internet!

  14. #14
    Emotionally Unstable DarkViper's Avatar
    Join Date
    Oct 2002
    Posts
    343
    i dont care what anyone says, BShed Dev C++ is my favorite compiler, and probably the reason you got hundreds of errors was because you had the wrong project options on. if its a window it has to be set to win32GUI and not win32Console. i know how to use BShed C++ well, and its a great compiler. the ones that cost money are a rip-off in my opinion. but thats just my opinon., dont take me seriously.
    ~DJ DarkViper signing out
    ----------------------------------------
    My Site:
    Black Jaguar Studios

    Languages:
    Fluent English, Starter German, HTML, Javascript, Actionscript, Intermediate PHP

    Verteran Despiser of: ASP, Java, BASIC, Pascal, Cobalt

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. We Got _DEBUG Errors
    By Tonto in forum Windows Programming
    Replies: 5
    Last Post: 12-22-2006, 05:45 PM
  2. C++ std routines
    By siavoshkc in forum C++ Programming
    Replies: 33
    Last Post: 07-28-2006, 12:13 AM
  3. load gif into program
    By willc0de4food in forum Windows Programming
    Replies: 14
    Last Post: 01-11-2006, 10:43 AM
  4. Errors with including winsock 2 lib
    By gamingdl'er in forum C++ Programming
    Replies: 3
    Last Post: 12-05-2005, 08:13 PM
  5. Learning OpenGL
    By HQSneaker in forum C++ Programming
    Replies: 7
    Last Post: 08-06-2004, 08:57 AM