SHARE
TWEET

C training

MaKiPL Oct 18th, 2016 (edited) 81 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. int main()
  2. {
  3.     int _switch = 0;
  4.     for (int i = 1; i < 6; i++)
  5.     {
  6.         _switch = i % 2 ? 0 : 1;
  7.         byte n = i;
  8.         char* c = malloc(n);
  9.         for (int k = 0; k < n; k++) {
  10.             char a = _switch ? '0' : '1';
  11.             *(c + k) = a;
  12.             _switch = _switch ? 0 : 1;
  13.         }
  14.         *(c + n) = 0x00;
  15.         printf("%s\n", c);
  16.     }
  17.     scanf("");
  18.     return 0;
  19. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top