output is blank :(

I switched from gotos to some voids. It was working before, I can't figure out what is wrong. Every time I debug it just displays "Press Any Key To Continue..." There are no system("pause"); 's in my code? I am very very confused. Please help.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
#include <iostream>
#include <io.h>
#include <sys/types.h> 
#include <sys/stat.h>
#include <cstdlib>
#include <time.h>
#include <windows.h>
#include <fstream>
#include <string>
#include <tchar.h>
#include <windows.h>

#define entuser "Enter Username [20] : "
#define noticepw " This is your Password, Keep it safe."
#define pathexistfile "The Directory You Entered is Actually a File." 
#define errorfile1 "Unable to open file."
#define direxist "The Directory Exists."
#define dirnoexist "The Directory Is Non-Existant."


using namespace std;

void foldercreation();
void loginpt1();
void loginpt2(); //names
void usercreation();
void optioncon();

int main()
{
string strPath;
strPath = "c:/u";
    if ( access( strPath.c_str(), 0 ) == 0 )
    {
        struct stat status;
        stat( strPath.c_str(), &status );

        if ( status.st_mode & S_IFDIR )
        {
            cout << direxist << endl; //the path exists
            loginpt1();
        }
        else
        {
            foldercreation();
        }
    }
}
void foldercreation()
{
cout << dirnoexist << endl; //folder u does not exists
cout << "Creating Folder..." << endl;
CreateDirectory("c:/u", NULL); //create folder
loginpt1();
}
void loginpt1()
{
char yesno;
cout << "Do you have a username? (Y/N)" << endl;
cin >> yesno;
if (yesno == 'Y')
{
    cin.ignore(yesno,10);
    cout << "YES" << endl;
    loginpt2();
}
if (yesno == 'N')
{
    cin.ignore(yesno,10);
    cout << "NO" << endl;
    usercreation();
}
else
{
    loginpt1();
}
}
void loginpt2()//yes
{
    string username;
    string folderfind = "C:/u/" + username;
    cout << entuser << endl;
cin >> username;
if ( access(folderfind.c_str(), 0 ) == 0 )
    {
        struct stat status;
        stat(folderfind.c_str(), &status );

        if (status.st_mode & S_IFDIR )
        {
            cout << direxist << endl; //the path exists
            optioncon();
        }
        else
        {
            cout << pathexistfile << endl; //the path is actually a file
        }
}
}
void optioncon()//yes
{
    int opt1;
    string username3;
    string line;
    string information;
cout << "Option Con";
cin >> opt1;
if (opt1 = '1')
{
    {
string filename2 = "C:/u/" + username3 + "/information.txt";
ofstream myfile;
myfile.open(filename2.c_str());
  myfile << cin << information << endl;
  myfile.close();

}

if (opt1 = '2')
{
string filename3 = "C:/u/" + username3 + "/information.txt";

ifstream myfilx (filename3.c_str());
  if (myfilx.is_open())
  {
    while (! myfilx.eof() )
    {
      getline (myfilx,line);
      cout << line << endl;
      myfilx.close();
    }
  }
  else
  {
      cout << errorfile1;
  }

}
}
}
void usercreation()//no
{
    string username2;
    string line;
cout << "User Creation";
cout << entuser;
cin >> username2;  //create a username
string path = "c:/u/" + username2;
CreateDirectoryA(path.c_str(), NULL); //make a folder with set username
string filename2 = "C:/u/" + username2 + "/password.txt"; //sets the filename to password directory

ofstream myfily;
myfily.open(filename2.c_str()); //create that file
  myfily << rand() << endl; //assign a random integer to password.txt
  myfily.close();

ifstream myfilo (filename2.c_str());
  if (myfilo.is_open())
  {
    while (! myfilo.eof() )
    {
      getline (myfilo,line);
      cout << line << endl;
      myfilo.close();
      cout << noticepw << endl; //this is your password
    }
  }
  else
  {
      cout << errorfile1;
    }
  


}
Are you confused about why it's showing "Press Any Key..."? It shows that at the end of your program because VC++ when debugging pauses the thing at the end.

As for why it writes nothing... curious. I cannot run this program as I am not on Windows and I unfortunately am pressed for time. Sorry. Hopefully someone else will be able to answer it.

-Albatross
Last edited on
It never actually runs my program. It just displays that, instead of all of that code. That is why I am confused.
Wait a minute... Are you sure your build is up to date?

-Albatross
Yes it is. I've rebuilt it 5 times. I've even copied and pasted the whole thing to a whole new c++ project and cpp file.
Update:
something is wrong with this code. It's supposed to find if c:/u/ exists and if not or anything else just go ahead and create the file. I have no idea how it works because this section is one of the things on my whole C++ page that is not mine. Now it's having errors. If you happen to know how this works, and can explain it to me in lame mans terms. It would be appreciated. Plus if you could possibly have a solution? I would be in your debt.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
string strPath;
strPath = "c:/u";
    if ( access( strPath.c_str(), 0 ) == 0 )
    {
        struct stat status;
        stat( strPath.c_str(), &status );

        if ( status.st_mode & S_IFDIR )
        {
            cout << direxist << endl; //the path exists
            loginpt1();
        }
        else
        {
            cout << dirnoexist << endl; //folder u does not exists
            foldercreation();
        }
    }
}
Topic archived. No new replies allowed.