Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- int n = 5;
- ///////////////////////////////////////////////////
- int main()
- {
- int *p = &n;
- printf("address n = %d\n", p);
- printf(" n = %d\n", *p);
- }
- /*
- #include <stdio.h>
- struct Cdog
- {
- int nAge;
- float fWeight;
- } dog1, dog2;
- Cdog dog3, dog4;
- void fDog(Cdog *p);
- ///////////////////////////////////////////////////
- int main()
- {
- Cdog dog5, dog6;
- dog3.nAge = 3;
- dog3.fWeight = 0.2;
- dog6.nAge = 11;
- dog6.fWeight = 1.241;
- fDog(&dog6);
- }
- ///////////////////////////////////////////////////
- void fDog(Cdog *p)
- {
- printf("nAge = %d \n", p->nAge );
- printf("fWeight = %.3f\n", p->fWeight);
- }
- */
- /*
- #include <stdio.h>
- void swap(int &p1, int &p2);
- void print(int *p, int n);
- ///////////////////////////////////////////////////
- int main()
- {
- int nArr[99] = {5, 11, 2, 6, 34, 1, 7};
- swap(nArr[0], nArr[4]);
- print(nArr, 7);
- }
- ////////////////////////////////////////////////////
- void print(int *p, int n)
- {
- for(int i = 0; i < n; i++)
- {
- printf("%d, ", p[i]);
- }
- printf("\n");
- }
- ///////////////////////////////////////////////////
- void swap(int &r1, int &r2) //
- {
- int n = r1;
- r1 = r2;
- r2 = n ;
- }
- */
- /*
- #include <stdio.h>
- void swap(int *p1, int *p2);
- void print(int *p, int n);
- ///////////////////////////////////////////////////
- int main()
- {
- int nArr[99] = {5, 11, 2, 6, 34, 1, 7};
- swap(&nArr[0], &nArr[4]);
- print(nArr, 7);
- }
- ////////////////////////////////////////////////////
- void print(int *p, int n)
- {
- for(int i = 0; i < n; i++)
- {
- printf("%d, ", p[i]);
- }
- printf("\n");
- }
- ///////////////////////////////////////////////////
- void swap(int *p1, int *p2) //
- {
- int n = *p1;
- *p1 = *p2;
- *p2 = n;
- }
- */
- /*
- #include <iostream>
- #include <string.h>
- #include <stdio.h>
- using namespace std;
- struct Dog
- {
- int Age;
- char color[99];
- float weight;
- };
- void foo(Dog *p);
- ///////////////////////////////////////////////////
- int main()
- {
- Dog y, u, w;
- y.Age = 4;
- u.Age = 8;
- w.Age = 5;
- w.weight=0.20;
- strcpy(w.color, "Blue" );
- strcpy(u.color ,"brown" );
- y.color[0] = 'B';
- y.color[1] = 'l';
- y.color[2] = 'a';
- y.color[3] = 'c';
- y.color[4] = 'k';
- y.color[5] = 0 ;
- foo(&w);
- }
- //////////////////////////////////////////////////////////
- void foo(Dog *p) //
- {
- printf("u.color = %s\n" , p->color );
- printf("u.Age = %d\n" , p->Age );
- printf("w.weight = %.2f\n", p->weight);
- }
- */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement