Thread: Why does this ouput random characters

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Registered User
    Join Date
    Sep 2006
    Posts
    5

    Why does this ouput random characters

    Code:
    #include <stdlib.h>	// for itoa() call
    #include <stdio.h>	// for printf() call
    
    char *convert(int value);
    
    int main() 
    {
    
     //print our string
     printf("%s\n", convert(123));
     getchar();
     return 0;
    }
    
    char *convert(int value)
    {
    	 char buf[5];
    	 return itoa(value, buf, 2);
    }
    Last edited by Ken Fitlike; 09-30-2006 at 04:57 PM. Reason: added code tags

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. HELP!!!!emergency Problem~expert please help
    By unknowppl in forum C++ Programming
    Replies: 9
    Last Post: 08-21-2008, 06:41 PM
  2. HELP!!!!emergency ~expert please help
    By unknowppl in forum C Programming
    Replies: 1
    Last Post: 08-19-2008, 07:35 AM
  3. Question for Random class
    By joenching in forum C++ Programming
    Replies: 2
    Last Post: 03-20-2005, 11:22 PM
  4. non repeating random number generation?
    By gencor45 in forum C# Programming
    Replies: 1
    Last Post: 02-08-2005, 05:23 PM
  5. Another brain block... Random Numbers
    By DanFraser in forum C# Programming
    Replies: 2
    Last Post: 01-23-2005, 05:51 PM