Been a while since I lurked /prog/, nice to see the userbase is still as dumb as shit.
Name:
Anonymous2009-05-18 22:34
/g/ already helped. Nevermind this post.
Name:
Anonymous2009-05-18 22:35
for (j=0; j<i; j++){
s2[j]=s[i-j];
}
the variable i will be the length of the first string. the largest value of j will be i minus one, leaving your final string as ?dbca???? since it starts at too high an index. make the core of the loop s2[j]=s[i-j-1]; and it should work.
How can I fix this?
Actually return a value from main as specified by the declaration.
Don't use gets().
Don't use C.
Dont use puts().
Don't take any more computer science classes.
Don't continue breathing.
>>24
What are p and pr for? They are completely unnecessary, making the code is highly bloated and redundant. There's also a fatal mistake: it'll write a \0 before the output string, very probably outside the provided destination buffer.
The sad thing is that it's still the best piece of code in this thread, by a few miles.
Name:
Anonymous2009-05-20 7:48
void evr(char *s, char *sr)
{
sr += strlen(s);
*sr-- = 0;
while (*s)
*sr-- = *s++;
}
That makes it longer. In order to successfully use #define to optimize it, you need to make sure the #define replaces at the very least, 11 (#define + 2 spaces + replace character + use of replace character for each instance) + replaced text length characters.
For example, with void, you would need to make sure it replaces no less than 15 characters. That's just to break even. The only things even close to being #define-compatible for optimization in that particular code excerpt are *r--= and char * and even those aren't close to a gain.
>>38 #define is preprocessor-code.
We need that anyway for the string.h, so just add those lines to the string.h, but call it s.h to save even more space.