Commit 53f485f9 authored by Zhaozhong Liu's avatar Zhaozhong Liu
Browse files

Prelab 1.2 complete

parent cd5a562d
No preview for this file type
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
void reverse_string(char *str, int len){
if (*str == '\0'){
return;
}
reverse_string(str + 1, len-1);
printf("%c", *str);
}
int main(int argc, char *argv[]){
if(argc != 2){
printf("erro\n");
}
else{
char *str = argv[1];
int len = strlen(str);
reverse_string(str, len);
}
}
#include <stdio.h>
#include <stdlib.h>
int main(int argc, char *argv[]){
char *s = argv[0];
int len = sizeof(s);
int i = 0;
char c;
while(i<=len/2-1){
c = *(s+i);
*(s+i) = *(s+len-1+i);
*(s+len -1 +i)= c;
i++;
}
printf("%s \n", s);
}
File added
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment