Hi All,
The program below is returning the following data...
A
1
AB
(empty line)
3
9
...when it should be returning...
A
1
AB
2
ABCDEFG
7
I've tried changing the assignment code statements to read MyString = MyString + "B\n"';
and MyString = MyString + "CDEFG\n";
, but that, expectedly, doesn't change any of the output, and I don't see any extra end-of-line characters. :confused: Can someone point me in the right direction?
// File Name: abc.cpp
// Project 4.2
// Author: (aeisntein, from text exercise)
// Date: 06.03.2006
#include <iostream> // necessary for cout command
#include "apstring.h" // point to apstring header file
int main()
{
// Declare empty string object MyString
apstring MyString;
// Assign value "A" to string object MyString
MyString = 'A';
// Output initial value of string object MyString
cout << MyString << endl;
// Output the length of initial value of string object MyString
cout << MyString.length() << endl;
// Concatenate character "B" to end of current value of string object MyString.
MyString += "B\n";
// Output current value of string object MyString
cout << MyString << endl;
// Output length of current value of string object MyString
cout << MyString.length() << endl;
// Concatenate string "CDEFG" to end of current value of string object MyString.
MyString += "CDEFG\n";
// Output length of current value of string object MyString
cout << MyString.length() << endl;
return 0;
}
TIA