File I/O

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

  1. iWill macrumors member

    Nov 24, 2006
    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:
    #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:
                    cout << "Now Enter The Number Matching The App You Want To Launche";
                    cin >> S2;
        void list()
        ifstream File("Name.txt");
    	char 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;
    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. Eraserhead macrumors G4


    Nov 3, 2005
    What language is it? Sorry if this is a stupid question :eek:.

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

    Nov 24, 2006
    Oh yea sry for not'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/ 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. iWill thread starter macrumors member

    Nov 24, 2006
    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. superbovine macrumors 68030


    Nov 7, 2003

Share This Page