S
sworna vidhya
Hai,
When viewing some queries of this group, i came across a function
which is similar to strcpy. The snip of the code is as follows:
#include <stdio.h>
#include <stdlib.h>
void myfunc(char *p, char *q)
{
while (*p = +*q++)
*p++;
}
void main()
{ char *str;
char *str1 = "apple";
str = NULL;
str = (char *) calloc (sizeof (str),sizeof (char *) * sizeof(str1));
myfunc(str,str1);
printf("\n\t Str : %s \n\t Str1 : %s \n",str,str1);
}
1. How the functionality process here?
while (*p = +*q++)
*p++;
2. Also, i noticed that the same query also contains the same function
can be written in the other way as follows:
void myfunc(char *p, char *q)
{
while (*(p++) = (*q)++);
}
But when i compile i found no error.
While running, i am getting exception with application error. Why i am
getting so?
Kindly clarify my doubts.
Thanks and Regards,
M.Sworna Vidhya
When viewing some queries of this group, i came across a function
which is similar to strcpy. The snip of the code is as follows:
#include <stdio.h>
#include <stdlib.h>
void myfunc(char *p, char *q)
{
while (*p = +*q++)
*p++;
}
void main()
{ char *str;
char *str1 = "apple";
str = NULL;
str = (char *) calloc (sizeof (str),sizeof (char *) * sizeof(str1));
myfunc(str,str1);
printf("\n\t Str : %s \n\t Str1 : %s \n",str,str1);
}
1. How the functionality process here?
while (*p = +*q++)
*p++;
2. Also, i noticed that the same query also contains the same function
can be written in the other way as follows:
void myfunc(char *p, char *q)
{
while (*(p++) = (*q)++);
}
But when i compile i found no error.
While running, i am getting exception with application error. Why i am
getting so?
Kindly clarify my doubts.
Thanks and Regards,
M.Sworna Vidhya