S
sven_tmp
Hi Richard,
I was not thinking in every detail about the
code pkirk25 posted. The main thing I wanted to say is that the
return in the FixString-function is not needed.
You always write about undefined behavior, I don't know exactly
why but I suggest it is because of the use of unchecked
pointer-variables.
Can you give me the answers to your quetions?
Thank you
Sven
I was not thinking in every detail about the
code pkirk25 posted. The main thing I wanted to say is that the
return in the FixString-function is not needed.
You always write about undefined behavior, I don't know exactly
why but I suggest it is because of the use of unchecked
pointer-variables.
Can you give me the answers to your quetions?
void FixString(char *strIn, char *strOut)
{
int i = 0;
int j = strlen(strIn);
Undefined behaviour. Bonus question: why?
for (i = 0; i <= j; ++i) {
/* removing the cleanup code for brevity on usenet */
strOut = strIn;
}
printf("%s\n", strOut);
Undefined behaviour. Bonus question: why?Undefined behaviour. Bonus question: why?char *strOut = "This is a line from a web page <br>";
int i = strlen(strOut);
Constraint violation. Bonus question: why?char *backBuff = malloc(i);Undefined behaviour. Bonus question: why?FixString(strOut, backBuff);Undefined behaviour. Bonus question: why?printf("%s\n", backBack); /* Prints out the string
perfectly */
At least you got main's return type right.
Thank you
Sven