I am trying to write a simple c++ program.
goal: open an existing text file, take name and surname and save them to name and surname strings. print name and surname and jump to the next line. repeat until the end of file.
I have 2 problems
I am using windows 8.1 and visual studio 2017 with latest update.
main code is below:
#include <stdio.h>
#include <stdlib.h>
#include <string>
#include "stdafx.h"
#include <iostream>
using namespace std;
int main() {
FILE *fPtr;
if ((fPtr = fopen("newStudentsList.txt", "r")) == NULL) {
cout << "File could not be opened.\n";
system("pause");
}
else {
char *name = new char[100];
char *surname = new char[100];
rewind(fPtr);
while (!feof(fPtr)) {
fscanf(fPtr, "%s\t%s\n", name, surname);
cout << name << " " << surname << endl;
}
system("pause");
}
return 0;
}
In output, i cannot see turkish characters properly. This is my first problem.
My second problem is that I cannot take names and surnames properly, since in text file they are not written with identical tabs or blanks and some people have one name some have two names.
All the files are here
How can I print non English characters?
How can I take names and surnames properly?