I am unable to get the part of the string stored in form of char array.
char code1 [12]={0};
char c;
string compressed_file;
I am taking the input from a text file, till a ',' occurs in it.
cout<<"Input compressed_file name"<<endl;
cin>>compressed_file;
string extracted_file;
cout<<"Input extracted_file name"<<endl;
cin>>extracted_file;
ifstream input;
input.open(compressed_file.c_str());
ofstream decompresscode;
decompresscode.open(extracted_file.c_str());
input>>c;
while(c != ',')
{
int i=0;
code1[i]=c;
cout<<code1[i];
i++;
input>>c;
}
int old=atoi(code1);
cout<<old;
After printing the value of code1 here, I am only getting the first letter of the array. My code1 is 66, it is printing only 6.
std::vector<char>instead of your array. This enables longer input and you would not need the variablei, select theback()element instead.