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.

Answer Posted / 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       View All Answers


Please Help Members By Posting Answers For Below Questions

What is a buffer in c?

958


What is else if ladder?

977


Wt are the Buses in C Language

3175


What is function prototype in c with example?

1022


In c language can we compile a program without main() function?

1082


Explain what is the difference between a string copy (strcpy) and a memory copy (memcpy)? When should each be used?

1054


how many errors in c explain deply

2054


Can we declare a function inside a function in c?

1003


Difference between linking and loading?

1077


Write a program, where i have a grid with many cells, how many paths are possible from one point to other desired points.

1200


Write a factorial program using C.

1036


What are operators in c?

985


What is indirection? How many levels of pointers can you have?

1104


What is the significance of an algorithm to C programming?

1013


What is c system32 taskhostw exe?

989