Find a word in string and extract int

Hi. i'm working on a login program that stores usernames/passwords in files. once the user logs in, the program opens a CSV file and searches for the entered username and extracts the (int) privilege associated with that user e.g. 1/2/3.

I can read the CSV file into the program, but how do I find the specific username, then extract the int.

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
#include <iostream>
#include <fstream>
#include <stdio.h>
#include <string.h>
#include <sstream>
using namespace std;


int main()
{
    int privilege;
    char filename [80];
    string line;
    string pass;

    cout << "Username: ";
    cin >> filename;
    cout << "Password: ";
    cin >> pass;
    ifstream myfile (filename);
    if (myfile.is_open())
    {
    while ( myfile.good() )
    {
      getline (myfile,line);
      if (pass == line)
      {
        fstream MyExcelFile ("Users.csv", ios::in | ios::out | ios::app);
        string Value;
        while (MyExcelFile.good() )
        {
        getline (MyExcelFile, Value, '\t');
        cout << Value;
        cout << "\n";

      }


    }
    myfile.close();
    return 0;
}}}


josh,1
user,2
guest,3


Any help would be greatly appreciated.
:)
1
2
3
4
5
while(getline(fileType, string)
{
     if(!isnum(line.c_str());
          username = line
}
Hi Aramil,
could you please explain how this code fits into mine. I'm not sure what you mean by (filetype, string)
But thanks for your quick reply.
yeah so it wasn't meant to work. ill make a function for you
Topic archived. No new replies allowed.