displayname
displayname

Reputation: 1

defining the start of a string in a CSV file to guarantee proper comparison

Im reading information from a CSV file and im getting random symbols at the start of my first input, my understanding is that compiler doesn't know where the start of the string is so looks for the first null pointer it can find in this case a comma in the CSV file, is there a way to correct this?

apologies in advance im not sure how to write the minimal code used on stack overflow and my project is due soon

#include <iostream>
#include <string.h>
#include <fstream>  
#include <sstream>  
using namespace std;

int main()
{
    string Name,Password;

    cout << "enter name\n" ;
    cin >> Name;

    cout >> "enter Password"
    cin >> Password;

    ifstream InFile('MyFile');

    string line;

    while (getline(InFile, line))
    {
        istringstream iss(line);    
        string NameIn, Password                                             

        if (getline(iss, NameIn,',') && getline(iss, Password, ','))
            if (NameIn = Name && PasswordIn == Password)
            {
                cout << "welcome " << name ;
            } 
    }

Upvotes: 0

Views: 46

Answers (0)

Related Questions