T
tonyjeffs2
Main() prints to screen "The name is ", and then uses a function to
print "Ivor Horton".
Additionally, the function contains some debugging code, which outputs
the text "Name::getName()called".
When I download the files from the internet, the output is:
Name::getName()called
The name is Ivor Horton
My own faithfully transcribed version yields a garbled version:
The name is
Name::getName()called Ivor Horton
Even when I delete all my own text and replace every bit of it with
the author's version, it still comes out in the wrong order. I'm
baffled.
I'm using C++express and this is a CLR blank project in both cases.
I can't find any difference, but I must be missing something.
Any suggestions welcome
Thanks tony
____________________________________________________
Here is part of my class main():
____________________________________________________
int main(int argc, char* argv[])
{
Name myName("Ivor", "Horton");
// Retrieve and store the name in a local char array
char theName[12];
cout << "\nThe name is " << myName.getName(theName);
.. . .
}
___________________________________________________
Here is the function getName()
___________________________________________________
char* Name::getName(char* pName) const
{
assert(pName != 0); // Verify non-null argument
#ifdef FUNCTION_TRACE
// Trace function calls
cout << "\nName::getName() called.";
#endif
strcpy(pName, pFirstname);
strcat(pName, " "); // Append a space
return strcat(pName, pSurname); // Append second name and
return total
}
print "Ivor Horton".
Additionally, the function contains some debugging code, which outputs
the text "Name::getName()called".
When I download the files from the internet, the output is:
Name::getName()called
The name is Ivor Horton
My own faithfully transcribed version yields a garbled version:
The name is
Name::getName()called Ivor Horton
Even when I delete all my own text and replace every bit of it with
the author's version, it still comes out in the wrong order. I'm
baffled.
I'm using C++express and this is a CLR blank project in both cases.
I can't find any difference, but I must be missing something.
Any suggestions welcome
Thanks tony
____________________________________________________
Here is part of my class main():
____________________________________________________
int main(int argc, char* argv[])
{
Name myName("Ivor", "Horton");
// Retrieve and store the name in a local char array
char theName[12];
cout << "\nThe name is " << myName.getName(theName);
.. . .
}
___________________________________________________
Here is the function getName()
___________________________________________________
char* Name::getName(char* pName) const
{
assert(pName != 0); // Verify non-null argument
#ifdef FUNCTION_TRACE
// Trace function calls
cout << "\nName::getName() called.";
#endif
strcpy(pName, pFirstname);
strcat(pName, " "); // Append a space
return strcat(pName, pSurname); // Append second name and
return total
}