Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...


Why is the code below functioning. According to me it MUST
NOT.



Why is the code below functioning. According to me it MUST NOT...

Answer / h0rryp0tter

Please have a look at the code below :

char str[1];
int i = 0;
void revstr(void);

int main(void)
{

revstr();
printf("%s\n",str);

return 0;
}

void revstr(void)
{
char c = getchar();

if (c!= EOF) {
revstr();
str[i++] = c;
}
str[i] = '\0';
}

Written using Bloodshed Dev C++.

I am trying to access and write on an char array which has
been defined with only one element in it. The above code
must give me Errors of some kind. But on the contrary, it
works.

Is This Answer Correct ?    0 Yes 1 No

Post New Answer

More C Interview Questions

write a statement to display all the elements array M(in reverse order? int M[8]={20,21,22,23,24,25,26,27};

5 Answers  


List some of the dynamic data structures in C?

0 Answers  


Difference between C and Embedded C?

1 Answers  


what are two categories of clint-server application development ?

1 Answers  


What is build process in c?

0 Answers  


How do I create a directory? How do I remove a directory (and its contents)?

0 Answers  


What is volatile, register definition in C

0 Answers   Cognizant,


WRITE A CODE IN C TO SEARCH A FILE FROM NOTEPAD FILE.

0 Answers   Google, Infosys,


What is the o/p of the follow pgm? #include<stdio.h> main() { char char_arr[5]=”ORACL”; char c=’E’; prinf(“%s\n”,strcat(char_arr,c)); } a:oracle b. oracl c.e d.none

2 Answers   Oracle,


What is difference between union and structure in c?

0 Answers  


Why n++ execute faster than n+1 ?

2 Answers  


Tell us the difference between these two : #include"stdio.h" #include<stdio.h> define in detial.

5 Answers  


Categories