All pastes #945554 Raw Edit

Untitled

public c v1 · immutable
·published 2008-03-17 00:52 UTC
rendered paste body
//In this code I create 3 pipes.//Since in the table 0 is STDIN 1 is STDOUT and 2 is STDERROR it will start assigning values //starting with 3.typedef int* my_type;my_type p[2];int t;for (t =0; t < 3; t++) {   int pipenum[2];   if (pipe(pipenum) == -1) {      perror("Failure of pipe");   }   p[t] = pipenum;   printf("P[%d][0] = %d and P[%d][1]= %d\n", t,p[t][0], t,p[t][1]);}printf("P[%d][0] = %d and P[%d][1]= %d\n", 1,p[1][0], 1,p[1][1]);//In the loop the values become//P[0][0] will be 3//P[0][1] will be 4//P[1][0] will be 5//P[1][1] will be 6//P[2][0] will be 7//P[2][1] will be 8//However if i printf immediately outside this function, lets say p[1][0] and p[1][1] it will say //the values are 7 and 8 instead of 5 and 6. Any idea how that can be?