📝 Added sandbox (code sketchbook)
This commit is contained in:
parent
b475595f7f
commit
b5daf18b1a
142 changed files with 100702 additions and 0 deletions
22
sandbox/reverse_string.c
Normal file
22
sandbox/reverse_string.c
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
/* https://www.w3schools.in/c-programming/examples/reverse-a-string-in-c */
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
int main(void) {
|
||||
char mystrg[60];
|
||||
int leng, g;
|
||||
|
||||
printf("Program in C for reversing a given string\n");
|
||||
printf("Please isnert the string you want to reverse: ");
|
||||
scanf("%s", mystrg);
|
||||
|
||||
leng = strlen(mystrg);
|
||||
|
||||
/* goes through the mystrg[] array backwards */
|
||||
for(g = leng - 1; g >= 0; g--) {
|
||||
printf("%c", mystrg[g]);
|
||||
}
|
||||
printf("\n");
|
||||
return 0;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue