Simple String question

This is a discussion on Simple String question within the C Programming forums, part of the General Programming Boards category; Why do we not pass the address of the string during printf or scanf functions like we do for Integer ...

  1. #1
    Registered User
    Join Date
    Jan 2013
    Location
    Kolkata
    Posts
    20

    Simple String question

    Why do we not pass the address of the string during printf or scanf functions like we do for Integer or float variable types?

    Thanks in advance.

  2. #2
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,532
    But you DO pass an address.

    You just don't use the & address-of operator.

    Code:
    char message[] = "hello";
    printf("%s",message);
    // is the same as
    printf("%s",&message[0]);
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  3. #3
    Registered User
    Join Date
    Jan 2013
    Location
    Kolkata
    Posts
    20
    Oh my. I missed that completely. Thanks a lot.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Simple string question
    By gareth00 in forum C Programming
    Replies: 12
    Last Post: 10-27-2008, 11:19 AM
  2. string simple question
    By -EquinoX- in forum C Programming
    Replies: 1
    Last Post: 04-12-2008, 01:28 PM
  3. simple question on std::string
    By MegaManZZ in forum C++ Programming
    Replies: 8
    Last Post: 01-25-2008, 11:18 AM
  4. Simple string question
    By RobJ in forum C Programming
    Replies: 6
    Last Post: 04-12-2006, 08:19 AM
  5. simple string question
    By c_cool in forum C Programming
    Replies: 4
    Last Post: 07-30-2004, 12:27 PM

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