string reversal in standard C
Are you simply trying to reverse a string? There are standard functions for this. Take a look below.
Sincerely,
Chris.
P.S. Avoid the use of "new" for variable names. This is a keyword in C++.
:)
Code:
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
int main(int argc, char* argv[])
{
char* cnew = (char*) malloc(256);
char* temp = (char*) malloc(256);
strcpy(cnew, "abcdefghijklmnopqrstuvwxyz1234567890");
strcpy(temp, cnew);
strrev(temp);
printf("%s\n", temp);
printf("\n%s", cnew);
free(cnew);
free(temp);
return 1;
}