Why does the following code not give an error?
#include<stdio.h>
void fun(char *a) //array decays to pointer here
{
a[0] = 'a';
printf("%s\n",a);
}
int main()
{
char p[]="hello";
fun(p);
getch();
}
if i write something like this in main
char *arr="hello"
arr[0] = 'r'; //this gives runtime error and i know why
--
You received this message because you are subscribed to the Google Groups
"Algorithm Geeks" group.
To view this discussion on the web visit
https://groups.google.com/d/msg/algogeeks/-/rxboAmI8lEUJ.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/algogeeks?hl=en.