pulling strings

This is a discussion on pulling strings within the C++ Programming forums, part of the General Programming Boards category; i'll admit it. i dont have a clue about strings. there. its out. imagine this code: (i dont have to. ...

  1. #1
    ...
    ... is offline
    Registered User
    Join Date
    Feb 2002
    Posts
    465

    pulling strings

    i'll admit it. i dont have a clue about strings. there. its out.

    imagine this code: (i dont have to. im looking at it now)

    char string[10] = "hi";
    printf("%s", string);

    i realize that doesnt work for some reason, but i havent the slightest why.

    any help?




    btw, it gives me a " 'string' undeclared " error.... i declared it, right?
    I came up with a cool phrase to put down here, but i forgot it...

  2. #2
    Ryan
    Guest
    char string[10] = "hi";
    printf("%s", &string);

  3. #3
    ...
    ... is offline
    Registered User
    Join Date
    Feb 2002
    Posts
    465
    didnt help...



    here is a better approximation of my code:

    if ( //something )
    char string[] = "hi";
    if ( //something else )
    char string[] = "bye";

    printf("%s", string); //(or &string... same error)
    Last edited by ...; 03-13-2002 at 06:03 PM.
    I came up with a cool phrase to put down here, but i forgot it...

  4. #4
    ryan
    Guest
    oops sorry hehe, its either:


    char string[10] = "hi";
    printf("%s", &string[10]);

    or

    char string[10] = "hi";
    printf("%s", string[10]);

  5. #5
    ...
    ... is offline
    Registered User
    Join Date
    Feb 2002
    Posts
    465
    *erased*



    woo! figured it out
    Last edited by ...; 03-13-2002 at 06:34 PM.
    I came up with a cool phrase to put down here, but i forgot it...

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Strings Program
    By limergal in forum C++ Programming
    Replies: 4
    Last Post: 12-02-2006, 02:24 PM
  2. Programming using strings
    By jlu0418 in forum C++ Programming
    Replies: 5
    Last Post: 11-26-2006, 07:07 PM
  3. Reading strings input by the user...
    By Cmuppet in forum C Programming
    Replies: 13
    Last Post: 07-21-2004, 06:37 AM
  4. damn strings
    By jmzl666 in forum C Programming
    Replies: 10
    Last Post: 06-24-2002, 02:09 AM
  5. menus and strings
    By garycastillo in forum C Programming
    Replies: 3
    Last Post: 04-29-2002, 11:23 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21