I'm making the password program thing (or at least editing it). I had some good help from people, the last post I made. They taught me some new good commands, but anyway. The code I have wont' work.
#include <iostream>
#include <fstream>
#include <cstring>
#include <cstdio>
#include <cstdlib>
usingnamespace std;
int main(int nNumberofArgs, char* pszArgs[])
{
string szUsername;
int SIZE = 100;
char chNewUsername[SIZE];
string line;
string szNewPassword;
string szPassword;
cout << "Type in your username.\n -";
cin >> szUsername;
if (szUsername == "new" || szUsername == "New" || szUsername == "update" || szUsername == "Update")
{
system("cls");
cin.clear();
ofstream WriteFile;
cout << "Type in your username or type in a new one.\n -";
cin >> chNewUsername;
system("cls");
cout << "Type in your new password.\n -";
cin >> szNewPassword[SIZE];
WriteFile.open(chNewUsername);
WriteFile << szNewPassword;
WriteFile.close();
}
else{
cin.clear();
cin >> szUsername;
ifstream ReadFile (szUsername);
if (ReadFile.is_open())
{
while ( ReadFile.good() )
{
system("cls");
getline (ReadFile,line);
cout << "Type your password.\n -");
cin >> szPassword;
if(szPassword == line)
{
system("cls");
cout << "Correct";
Sleep(200)
return;
}
ReadFile.close();
} ;
else{
system("cls");
cout << "Wrong Password";
system("pause>nul");
};
}
}
Here are the errors:
G:\Flash drive\C++ Programs\Drue Made\Read a text file\main.cpp||In function 'int main(int, char**)':|
G:\Flash drive\C++ Programs\Drue Made\Read a text file\main.cpp|57|error: no matching function for call to 'std::basic_ifstream<char, std::char_traits<char> >::basic_ifstream(std::string&)'|
c:\program files\codeblocks\mingw\bin\..\lib\gcc\i386-pc-mingw32\4.4.0\..\..\..\..\include\c++\4.4.0\fstream|442|note: candidates are: std::basic_ifstream<_CharT, _Traits>::basic_ifstream(const char*, std::_Ios_Openmode) [with _CharT = char, _Traits = std::char_traits<char>]|
c:\program files\codeblocks\mingw\bin\..\lib\gcc\i386-pc-mingw32\4.4.0\..\..\..\..\include\c++\4.4.0\fstream|428|note: std::basic_ifstream<_CharT, _Traits>::basic_ifstream() [with _CharT = char, _Traits = std::char_traits<char>]|
c:\program files\codeblocks\mingw\bin\..\lib\gcc\i386-pc-mingw32\4.4.0\..\..\..\..\include\c++\4.4.0\iosfwd|86|note: std::basic_ifstream<char, std::char_traits<char> >::basic_ifstream(const std::basic_ifstream<char, std::char_traits<char> >&)|
G:\Flash drive\C++ Programs\Drue Made\Read a text file\main.cpp|64|error: expected ';' before ')' token|
G:\Flash drive\C++ Programs\Drue Made\Read a text file\main.cpp|70|error: 'Sleep' was not declared in this scope|
G:\Flash drive\C++ Programs\Drue Made\Read a text file\main.cpp|71|error: expected ';' before 'return'|
G:\Flash drive\C++ Programs\Drue Made\Read a text file\main.cpp|79|error: expected '}' before 'else'|
||=== Build finished: 5 errors, 0 warnings ===|
G:\Flash drive\C++ Programs\Drue Made\Read a text file\main.cpp||In function 'int main(int, char**)':|
G:\Flash drive\C++ Programs\Drue Made\Read a text file\main.cpp|60|error: no matching function for call to 'std::basic_ifstream<char, std::char_traits<char> >::open(std::string&)'|
c:\program files\codeblocks\mingw\bin\..\lib\gcc\i386-pc-mingw32\4.4.0\..\..\..\..\include\c++\4.4.0\fstream|495|note: candidates are: void std::basic_ifstream<_CharT, _Traits>::open(constchar*, std::_Ios_Openmode) [with _CharT = char, _Traits = std::char_traits<char>]|
G:\Flash drive\C++ Programs\Drue Made\Read a text file\main.cpp|65|error: expected ';' before ')' token|
G:\Flash drive\C++ Programs\Drue Made\Read a text file\main.cpp|72|error: return-statement with no value, in function returning 'int'|
||=== Build finished: 3 errors, 0 warnings ===|