char array

How would i compare the cout data to a literal ex: 0, 1, 2, 3...
The program should compare the data and perform isalpha, islower, etc.

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
#include <iostream>
#include <fstream>
#include <cstring>
#include <cctype>
using namespace std;


int main()
{
	const int SIZE = 50;
	char data[SIZE];

	fstream inFile;
	inFile.open("test.txt", ios::in);

	inFile.getline(data, SIZE);
	while (!inFile.eof())
	{
		cout << data << endl;
		inFile.getline(data, SIZE);
	}
	
	
	
system("pause");
return 0;
}
I dont quite understand what you're saying, but ill take a guess. You want to compare the array with data? If you want to convert a char array holding ints into an Int, you use the following code: data[i] = data[i] - '0' which removes the ascii value. And if you want to store the data you could write the file into varibles like this small program:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
//Reading Custom File Structures
#include <iostream>
#include <fstream>
using namespace std;

int main()
{
  ifstream Traits("Players.txt");
  int id;
  string name;
  double money;

  while(Traits >> id >> name >> money){
    cout << id << ", " << name << ", " << money << " \n";
  }
}
Topic archived. No new replies allowed.