Ejemplo n.º 1
0
/**
 * (Edit this function to print out the ten "Illinois" lines in mp1-functions.c in order.)
 */
int main()
{

	first_step(81);
	
	int * two= malloc(sizeof(int));
	*two= 132;
	second_step(two);
	free(two);
	
	int ** three= malloc(sizeof(int *));
	three[0]= malloc(sizeof(int));
	*three[0]= 8942;
	double_step(three);
	free(three[0]);
	free(three);

	int * four=0;	
	strange_step(four);

	char * five= calloc(4,sizeof(char));
	empty_step((void*)(five));
	free(five);

	char * s2= calloc(4,sizeof(char));
	s2[3]='u';
	void * s= s2;
	two_step(s, s2);
	free(s2);

	char * first= 0;
	char * second= first+2;
	char * third= second+2;
	three_step(first, second, third);	

	first= calloc(2,sizeof(char));
	first[1]= 0;
	second= malloc(3*sizeof(char));
	second[2]= first[1]+8;
	third= malloc(4*sizeof(char));
	third[3]= second[2]+8;
	step_step_step(first, second, third);
	free(first);
	free(second);
	free(third);

	char * nine= malloc(sizeof(char));
	*nine= 1;
	it_may_be_odd(nine, 1);	
	free(nine);

	int * orange= malloc(sizeof(int));
	*orange= 513;
	int * blue= orange;
	the_end((void *)orange,(void *) blue);	
	//printf("temp= %d\n", (*temp));
	free(orange);
	return 0;
}
Ejemplo n.º 2
0
/**
 * (Edit this function to print out the ten "Illinois" lines in functions.c in order.)
 */
int main()
{
	first_step(81);
	
	int second_value = 132;
	int *second_p = &second_value;
	second_step(second_p);

	
	int third_value = 8942;
	int *third_p = &third_value;
	int **third_pp = &third_p;
	double_step(third_pp);

	int *forth_value = 0;
	strange_step(forth_value);

	void *fifth_value[] = {0, 0, 0, 0};
	empty_step(fifth_value);
	
	char *s2 = "uuuu";
	void *s = s2;
	two_step(s, s2);
	
	char *first, *second, *third;
	first = 0;
	second = first + 2;
	third = second + 2;
	three_step(first, second, third);
		
	char *arr = malloc(4*sizeof(char));
	arr[1] = 'a';
	arr[2] = arr[1] + 8;
	arr[3] = arr[2] + 8;
	step_step_step(arr, arr, arr);
	free(arr);
	
	int b = 1;
	void *a = &b;
	it_may_be_odd(a, b);	
	
	int end = 1281;
	void *orange, *blue;
	orange = blue = &end;
	the_end(orange, blue);	
	
	return 0;
}
Ejemplo n.º 3
0
/**
 * (Edit this function to print out the ten "Illinois" lines in part2-functions.c in order.)
 */
int main()
{
	first_step(81);
	int x = 132;
	int* y = &x;
	second_step(y);
	int *ww[1];
	*y = 8942;
	ww[0] = y;
	
	double_step(ww);
	void* ss = malloc(sizeof(int)*15);

	*(int*)(ss+5) = 15;
	strange_step(ss);
	*(char*)(ss+3) = 0;
	empty_step(ss);
	char a[4];
	a[3] = 'u';
	void* wwww;
	wwww = (void* )a;
	two_step(wwww, a); 
	
	three_step(a,a+2,a+4);
	free(ss);
	char b[4];
	b[1] = 'A';
	b[2] = 'A'+8;
	b[3] = 'A'+16;
	step_step_step(b,b,b);
	int sd = 'A';
	it_may_be_odd(b+(sizeof(char)), sd);
	char i[] = "C,CS241,41";
	tok_step(i);
	
	void* www;	
	x = 4353;
	www = (void*)&x;
	the_end(www,www);
	
	return 0;
}
Ejemplo n.º 4
0
/**
 * (Edit this function to print out the ten "Illinois" lines in part2-functions.c in order.)
 */
int main()
{
	//1
	first_step(81);

	//2
	int two = 132;
	second_step( &two );

	//3  ????

	int three =8942;
	int * threeP = &three;

	double_step(&threeP);

	//4
	int * four = 0;	
	strange_step(four);

	//5
	char five[4];
	five[3] =0;
	empty_step(five);

	//6
	char * six1, six2[4];
	six2[3] = 'u';
	six1= six2;	
	
	two_step(six1, six2);

	//7

	char * seven1;
	char * seven2;
	char * seven3;
	//seven2 = malloc(sizeof(char));
	seven1 = malloc(sizeof(char));
	//seven3 = malloc(sizeof(char));
	seven2 = seven1 + (char) 2;	
	seven3 = seven2 + (char) 2;

	three_step(seven1, seven2, seven3);
	
	free(seven1);
	
	//8
	char eight1[2];
	eight1[1] = 'b';

	char eight2[3];
	eight2[2] = 'b' + 8;	

	char eight3[4];
	eight3[3] = eight2[2] + 8;
	step_step_step(eight1, eight2, eight3);
	
	//9
	char * nineA = malloc (sizeof(char));
	int    nineB = 1;

	*nineA = (char) 1;

	it_may_be_odd(nineA, nineB);
	free(nineA);

	//10
	char * tenB = malloc(4*sizeof(char));
	int *  tenO = (int*) tenB;
	tenB[0] = (char) 1;
	tenB[1] = 2;
	
	the_end(tenO, tenB);
//((char *)blue)[0] == 1          *((int *)orange) % 3 == 0)


	return 0;

}
Ejemplo n.º 5
0
int main()
{
	/*
	 * [Part 1]:
	 *   Edit the provided part1.c file to print out the tweleve "Illinois" lines
	 *   that are provided in the code inside mp1-functions.c.
	 */
        
        //pass 81 value to print first Illinois.
        first_step(81);
        
        // initialize a varaible with value 132 and pass its pointer as an argument.
        int val = 132;
        second_step(&val);

        // pass a double pointer to string which has value 8942 as its value.
        // int double_val = 8942;
        int** pp = (int **) malloc(sizeof(int*));
        *pp = (int *) malloc(sizeof(int)); 
        *pp[0] = 8942;
        double_step(pp);

        free(*pp);
        free(pp);
        // initialize a pointer value to zero and pass it to strange_step function.
        int* p_val = 0;
        strange_step(p_val);

        // pass a character array whose fourth value is zero.
        int name[4] = {0};
        empty_step(name);

        // create a character array and pointer to that array.
        char s[4];
        char* s1;
        s1 = s;
        s[3] = 'u';
        two_step(s, s1);

        // create a character array and assign other these values.
        char first[10];
        char* second = first + 2;
        char* third = second + 2;
        three_step(first, second, third);

        // use above arrays assign values in such away that they will call this.
        *first = 0;
        *second = *first + 4;
        *third = *second + 4;
        triple_step(first, second, third);
        
        // use the above arrays to call third
        //third = second = first; 
        first[1] = 0;
        second[2] = first[1] + 8;
        third[3] = second[2] + 8;
        step_step_step(first, second, third);         

        // everything is set just call above function.
        triple_three_step_step_step(first, second, third);

        // create an integer which is less than 256
        int b = 10;
        char* a = (char* )&b;
        it_may_be_odd(a, b);

        // create an integer array with initial value 0;
        p_val =(int *) malloc(sizeof(int));
        *p_val = 513;
        the_end(p_val, p_val);
        free(p_val);

	return 0;
}