#include "stdafx.h"
#include <fstream>
#include <iostream>
#include <sstream>
#include <string>
using namespace std;
int main(int argc, char* argv[])
{
ifstream input("input.txt");
string names[20];
string temp;
int vote=0;
int votes[10];
for(int i =0; i < 20; i++)
{
input>>temp;
if (strcmp(temp,"9")>0)
{
names[i]=temp;
}
else
{
break;
}
}
}
So I want to read in a file and store every name(ie. James Tylon) into a string
array and when it detect an int
, it will stop.
However when I use this approach, error comes out.
error C2664: 'strcmp' : cannot convert parameter 1 from
'class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >'
to 'const char *'