I'm having issues with a rather simple program that prints a string.
I have two .cpp files, main and login, with login.h header file.
The problem at hand is that when I want to print the string in main.cpp that was entered from login.cpp - nothing is shown in which I assume the string is not being returned correctly.
main.cpp :
#include <iostream>
#include <fstream>
#include <string>
#include "login.h"
using namespace std;
string pfile;
int main () {
login(pfile);
cout << "Main." << endl;
cout << pfile;
return 0;
}
login.cpp:
#include <iostream>
#include <fstream>
#include <string>
using namespace std;
string login(string pfile) {
cout << "Login." << endl;
getline(cin, pfile);
return pfile;
}
login.h:
#include <string>
using namespace std;
#ifndef LOGIN_H
#define LOGIN_H
string login(string);
#endif