sprintf question

This is a discussion on sprintf question within the C Programming forums, part of the General Programming Boards category; //Definitions: Code: byte string[20]; Code: byte location_list[100][15]; what does the "-12.12" bit do? Code: sprintf( location_list[1], "%-12.12s", string );...

  1. #1
    Registered User
    Join Date
    Apr 2004
    Posts
    28

    sprintf question

    //Definitions:

    Code:
    byte		string[20];
    Code:
    byte location_list[100][15];
    what does the "-12.12" bit do?

    Code:
    sprintf( location_list[1], "%-12.12s", string );

  2. #2
    & the hat of GPL slaying Thantos's Avatar
    Join Date
    Sep 2001
    Posts
    5,681
    - means to left justify the output
    first 12 means to use at least 12 characters in the output
    .12 means to show 12 characters after the decimal

  3. #3
    Registered User
    Join Date
    Apr 2004
    Posts
    28
    cheers thantos

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Sprintf overflows my buffer -- why?
    By Lasston in forum C Programming
    Replies: 26
    Last Post: 06-20-2008, 04:33 PM
  2. Debugging question
    By o_0 in forum C Programming
    Replies: 9
    Last Post: 10-10-2004, 05:51 PM
  3. Question about pointers #2
    By maxhavoc in forum C++ Programming
    Replies: 28
    Last Post: 06-21-2004, 12:52 PM
  4. Question...
    By TechWins in forum A Brief History of Cprogramming.com
    Replies: 16
    Last Post: 07-28-2003, 09:47 PM
  5. Question, question!
    By oskilian in forum A Brief History of Cprogramming.com
    Replies: 5
    Last Post: 12-24-2001, 12:47 AM

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