locked
REALLY NUBE Question RRS feed

  • Question

  • User-1442885646 posted

    Okay I am taking a C++ course.

    I have to write a program according to the specs given.

    I have a variable:

    char Name[20];

    Later in the program I need to set the value of Name[] to, say "John Doe"

    How the heck do I do that?

    I can't have to set each character in the array:

    Name[1] = 'J';

    Name[2] = 'o';

    I could, but that CAN'T be it. That is too crazy.

    How do I do this???

    (This is a really stupid question, but I can't seem to figure this out).

    Thanks.

    Thursday, June 22, 2006 9:11 PM

All replies

  • User-1442885646 posted

    I got it. It's the strcopy command.

    I think I prefer VB.Net...

    Monday, June 26, 2006 7:53 AM
  • User779750837 posted
    Actually, your class is just using constructs that are too simple. C++ has String classes that are much easier to work with. You would have the same issues in VB.NET or C# if you tried to work exclusively with the char data type and char arrays thus forgoing the String class. However, as you point out, it would be pointless and counter productive. The main thing in C++ though is to understand the concept of how it handles data structures and pointers. This is the point in a beginners class that forces you to work with char arrays and such...
    Wednesday, June 28, 2006 9:27 AM