Thread: string generates

  1. #1
    Musicman - Canora
    Join Date
    Aug 2005
    Location
    Melbourne
    Posts
    252

    string generates

    Hey guys i automatically generated a number just want to ask a few questions.

    How would i only generate 4 integers using rand() also

    Thus far it prints

    'c'

    '23567' some random number how would i add the 'c' to the random number

    c23567

    Im trying to use a string cat function but getting some errors


    Code:
    #include <stdlib.h>
    #include <stdio.h>
    #include <string.h>
    
    int main (void)
    {
      char buff [200];
      int  number;
    
      sprintf(buff, "%s", "c");
    
      printf("%s\n\n", buff);
      
    
      number = rand();
      printf("%d", number);
    
    
      return EXIT_SUCCESS;
    
    }

  2. #2
    End Of Line Hammer's Avatar
    Join Date
    Apr 2002
    Posts
    6,231
    When all else fails, read the instructions.
    If you're posting code, use code tags: [code] /* insert code here */ [/code]

  3. #3
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    Hope is the first step on the road to disappointment.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. C++ ini file reader problems
    By guitarist809 in forum C++ Programming
    Replies: 7
    Last Post: 09-04-2008, 06:02 AM
  2. can anyone see anything wrong with this code
    By occ0708 in forum C++ Programming
    Replies: 6
    Last Post: 12-07-2004, 12:47 PM
  3. Something is wrong with this menu...
    By DarkViper in forum Windows Programming
    Replies: 2
    Last Post: 12-14-2002, 11:06 PM
  4. Classes inheretance problem...
    By NANO in forum C++ Programming
    Replies: 12
    Last Post: 12-09-2002, 03:23 PM
  5. Warnings, warnings, warnings?
    By spentdome in forum C Programming
    Replies: 25
    Last Post: 05-27-2002, 06:49 PM