Good day everyone!..
im having difficulty to merge this two program..in this code the data in the text file are tokenize it has the delimiter ","..
#include<iostream>
#include<conio.h>
using namespace std;
int main()
{
string str = "ako reiku xian";
size_t length;
char buffer[str.length()];
length=str.copy(buffer,str.length(),0);
buffer[length]='\0';
char *pch = buffer;
pch = strtok (pch," ");
while (pch != NULL)
{
cout<<pch<<",";
pch = strtok (NULL, " ");
}
getch();
}
-------------------------------
in this code the program show only the folder name that is being saved in the text file but its not yet being tokenize w/ the delemiter of ","
#include<iostream>
#include <fstream>
#include <dirent.h>
#include <unistd.h>
#include <sys/stat.h>
#include <sys/types.h>
using namespace std;
int main()
{
ifstream fin;
string dir, filepath, username, password;
int num;
DIR *dp;
struct dirent *dirp;
struct stat filestat;
dir = "C:\\Users\\ROAN\\Desktop\\folder";
cout<<"Enter username: ";
getline( cin, username );
cout<<"Enter password: ";
getline( cin, password );
dp = opendir( dir.c_str() );
while ((dirp = readdir( dp )))
{
string un, pw, folder;
filepath = dir + "/" + dirp->d_name;
if (stat( filepath.c_str(), &filestat )) continue;
if (S_ISDIR( filestat.st_mode )) continue;
fin.open( filepath.c_str() );
if (getline( fin, un ) && getline( fin, pw ))
if (un == username && pw == password)
{
getline(fin, folder);
cout << folder << endl;
}
fin.close();
}
closedir( dp );
system("pause");
return 0;
}