File I/O

Discussion in 'Mac Programming' started by iWill, Feb 25, 2007.

  1. macrumors member

    #1
    Sry if this is too windows specific but i really need help... So I'd like to scan program files and add the names of each program in a file with each of their paths. Is it possible? This is where i"m stuck:
    Code:
    #include <iostream>
    #include <windows.h>
    #include <fstream>
    using namespace std;
    
    int main()
    {
        int S1, S2;
        void list();
        void data();
        char word[25];
        
        cout << "\t\t   *****Ultimate App Launcher*****\n\n";
        cout << "[1] To Launch An App, [2] To Add an App To The List";
        cin >> S1;
         
        switch (S1)
        {
               
               case 1:
                    list();
                    cout << "Now Enter The Number Matching The App You Want To Launche";
                    cin >> S2;
                    
    	
        
        
        
        
        void list()
     {
        ifstream File("Name.txt");
    
    	char txt;
    	while(!File.eof())
    	{
    		File.get(txt);
    		cout << txt;
    	}
    	
        if (!File)
        {
                  cout <<  cout << "Cannot Open File. You Are Missing a File of Name **Name.txt**\n\nLocate It, Then Place It Next To The Program File.\n\n";
                 return 1;
        }
        
        File.close();
    }
    I'd like to know if i can directly read from program files, and how i could associate each app to a number so that the user only needs to type in the number to launch his application.
    Thanks in advance
     
  2. macrumors G4

    Eraserhead

    #2
    What language is it? Sorry if this is a stupid question :eek:.

    PS Please indent your code, it helps with reading it.
     
  3. macrumors member

    #3
    Oh yea sry for not precising...it's in C++
    For this program i was also thinking of dedicating one line to the program name and then the next line to it's path in the File I/O...like that each line with an even number would correspond to the program name and vice versa for the path of each program...would this be feasible?
     
  4. macrumors member

    #4
    Ok....another more precise question (sorry i know i'm being kinda vague):
    is it possible to compute the line numbers of a text file in C++? So that when the user enters 2, my program would read line number two of the text file?
     
  5. macrumors 68030

    superbovine

    #5

Share This Page