short function

czxcccscsdD
Last edited on
Did you copy and paste this file to your project, or make it yourself?
54564646
Last edited on
So you have a function and you need to cut it in half, and understand it?
no this is in our course book
Which book do you have? I can see quite an error on line 12
90980ik,cv
Last edited on
It may have compiled but it assigned the "y" to ch instead of comparing them.
Yeah, you probably made a typo when copying it in. And in any case the first step to simplifying the function would be to figure out what it does.
565fhjb
Last edited on
You started from the wrong project template in VC++
qqqq
Last edited on
Start from an Empty Project
This is shorter - but is it any less 'readable' ?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
void menu_display(char* file)
{
    char path[FILENAME_MAX + 4] = {'\"'};
    getcwd(&path[1],FILENAME_MAX );      //get the current directory
    char ch = 0;
    while(ch != 'N')
    {
        cout << "Do you want to open " << file <<" for reading? (Y,N):";
        if(cin >> ch, ch == 'Y')
        {
            strcat( strcat (strcat(path,"\\Debug\\Maagar\\"), file),"\"") ;
            system(path);
            break;
        }
    }
}
Last edited on
Topic archived. No new replies allowed.