Guest User

Untitled

a guest
Apr 19th, 2018
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.65 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4. int main ()
  5. {
  6.   int i,n;
  7.   char *  buffer;
  8.   int stala;
  9.         stala = 5;
  10.   printf ("How long do you want the string? ");
  11.   scanf ("%d", &i);
  12.  
  13.   buffer = (char*) malloc( 5 * sizeof( char));
  14.   if (buffer==NULL) exit (1);
  15.  
  16.   for (n=0; n<i; n++)
  17.     buffer[n]=rand()%26+'a';
  18.   buffer[i]='\0';
  19.         int x, y ;
  20.         x = sizeof(buffer);
  21.         y = sizeof(*buffer);
  22.         printf("\n buffer = %d   ||    *buffer = %d", x, y);
  23.  
  24.   printf ("Random string: %s\n",buffer);
  25. printf("\n %d \n", sizeof(*buffer));
  26. printf("\n %d \n", sizeof(buffer));
  27.  
  28.  free (buffer);
  29.  
  30.   return 0;
  31. }
  32. ~
Add Comment
Please, Sign In to add comment