files

This is a discussion on files within the C++ Programming forums, part of the General Programming Boards category; is there a way to jump to a seperate file with code? for example Code: #include <iostream> using namespace std; ...

  1. #1
    Registered User
    Join Date
    Sep 2005
    Posts
    142

    files

    is there a way to jump to a seperate file with code?

    for example

    Code:
    #include <iostream>
    
    using namespace std;
    
    int main()
    
    {
    
    int x;
    
    cout<<"choose from menu\n";
    cout<<"1, search phone book\n";
    cout<<"2, edit phone book\n";
    cout<<"\n";
    cout<<"input : ";
    
    cin>> x;
    
    switch ( x ) 
    
    {
    
    case 1:
              cout<<"goto different file";
              cin.get();
              break;
    
    case 2:
              cout<<"goto different file";
              cin.get();
              break;
    
    default:
              cout<<"incorrect input";
              cin.get();
              break;
    }
    
    
    }
    WhAtHA hell Is GoInG ON

  2. #2
    Supermassive black hole cboard_member's Avatar
    Join Date
    Jul 2005
    Posts
    1,709
    Yes. Just open the file and process it as required - I'd create two functions (one for choice 1 one for choice 2) that process each file as necessary.

    Code:
    switch ( x ) 
    {
    case 1:
              SearchPhoneBook();
              break;
    
    case 2:
              EditPhoneBook();
              break;
    
    default:
              cout<<"incorrect input";
              cin.get();
              break;
    }
    Good class architecture is not like a Swiss Army Knife; it should be more like a well balanced throwing knife.

    - Mike McShaffry

  3. #3
    Registered User
    Join Date
    Mar 2002
    Posts
    1,595
    Each file stream can be associated with only one file at a time. However, you can have multiple file streams in any given project and you can change files associated with a given stream as long as you close the first file before associating the stream with the second file.
    You're only born perfect.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Ressources files
    By mikahell in forum Windows Programming
    Replies: 4
    Last Post: 06-19-2006, 07:50 AM
  2. add source files to embedded VC 4.0
    By George2 in forum C++ Programming
    Replies: 4
    Last Post: 06-13-2006, 04:28 AM
  3. *.cpp and *.h files understanding
    By ElastoManiac in forum C++ Programming
    Replies: 4
    Last Post: 06-11-2006, 05:45 AM
  4. Linking header files, Source files and main program(Accel. C++)
    By Daniel Primed in forum C++ Programming
    Replies: 3
    Last Post: 01-17-2006, 11:46 AM
  5. Multiple Cpp Files
    By w4ck0z in forum C++ Programming
    Replies: 5
    Last Post: 11-14-2005, 02:41 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21