/* STRING REVERSE - STRREV */ #include<stdio.h> int main() { char str[100]; int i,j; char c; printf("Please enter a string: "); // gets(str); // fgets is a better option over gets to read multiword string . fgets(str, 100, stdin); // Following can be added for extra precaution for '\n' character // if(str[length(str)-1] == '\n') str[strlen(str)-1]=NULL; for(i=0;str[i];i++); for(j=0,i--;j<i;j++,i--) { c=str[i]; str[i]=str[j]; str[j]=c; } printf("Reversed string is: %s",str); return 0; }
String Reverse - STRREV
Subscribe to:
Post Comments (Atom)
for what is the 100 in the>>> char str[100];
ReplyDeletearray size, the number or chars it can store
Deleteis ter any simple program for this
Deletemnbk jjk kjlj k lkljl
Deletehoping it may work
nice article for beginners.thank you.
ReplyDeletewelookups C++
javacodegeeks
Tranh dán tường/
ReplyDeleteTranh treo tường 3D
In UV
ReplyDeleteCodeworld19
codeworld19 C and c++, codeworld19 Java, codeworld19 Python, codeworld19 Database sql,mongoDB, Hadoop, codeworld19 All hacker rank problem solutions