Advertisement
Guest User

Untitled

a guest
Sep 25th, 2017
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.87 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <string.h>
  3. #include <conio.h>
  4. #include <iostream>
  5.  
  6. using namespace std;
  7.  
  8. char c;
  9.  
  10. int garbage_function()
  11. { char c;
  12.   cout << "press a key";
  13.   cin >> c;
  14. }
  15.  
  16.  
  17. int main()
  18. {
  19.   char c;
  20.   char str_a[20];            // a 20 element character array
  21.   char *pointer;             // a pointer, meant for a character array
  22.   char *pointer2;            // and yet another one                  
  23.  
  24.   strcpy(str_a, "Hello World\n");
  25.   pointer = str_a;           // set the first pointer to the start of the array
  26.   printf(pointer);          
  27.  
  28.  
  29.   pointer2 = pointer + 2;    //set the second one 2 bytes further in.
  30.   printf(pointer2);          //print it
  31.   strcpy(pointer2, "y you guys!\n");           //copy into that spot
  32.   printf(pointer);                             //print again.
  33.  
  34.   cout << "press a key to continue";
  35.   cin >> c;
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement