if (InFile.is_open())
{
while ( InFile.good() )
{
getline (InFile,line);
for(int i = 0; i < line.length(); i++)
{
Memory[MemIndex] = line[i] ;
MemIndex++;
}
}
}
}
void OutputMemoryToFile(char Memory [], ofstream& Out)
{
string line; // a single line from file.
int MemIndex = 0;
if (Out.is_open())
{
int i = 0;
while ( Memory[i] != '\0')
{
Out<<Memory[i];
i++;
}
}
}
void DocumentStatisticsPrint(char Memory[])
{
int NumberWords = 0;
int i = 0;
while ( Memory[i] != '\0')
{
if(Memory[i] == ' ')
NumberWords ++;
cout<<Memory[i];
i++;
}
cout<<endl;
cout<<NumberWords<<" is number of words "<<endl;
cout<<"Number of Characters (Including Spaces)"<<i<<endl;
cout<<"Number of Characters (Excluding Spaces)"<<i - NumberWords <<endl;
}
int main(){
const int MAXNUMCHARS = 100000;
char Memory[MAXNUMCHARS];
the array is of type char which holds 100000 characters.
is it also possible to insert and delete strings and not chars into the char array.
will there be any conversion and copying done here.
and example code would be appreciated.
Why do you have a char array with 100,000 characters? o.O and I believe you have to do like strcpy() to put a string into a char array but that's kind of odd also.