🗽
🗽
🗽
🗽
C/Cpp and OS
Search…
Guide
Templates and methods
Linked List with C
Linked List with C++
Stacks with C
Queues with C
Graphs with C/C++
Trees with C/C++
DS with C
Reverse Linked List
Implement Queue with LL
Find mid of LL without traverse
Delete a Node from LL
Create a Binary search tree
String and Array
Reverse string
implement strcmp in C
Maximum Subarray
CTCI
Ch 01 - Arrays and Strings
Ch 02 - Linked List
Algorithm
Bubble Sort
Insertion Sort
Merge Sort
Count Prime
Basic Concept in C
Understand about pointer
Pre/Post Increment Operator
string and constant charaters
buffer overflow
Short-circuit evaluation
Allocate memory for 2D array dynamically
OS review
For beginner
Reference
Question Collecting:
References
Template on Linux
Powered By
GitBook
Reverse string
Explanation
C version
1
#include <stdio.h>
2
3
void reverse (char* string){
4
5
char *end = string;
6
while(*end != '\0'){
7
end++;
8
}
9
end--;
10
11
12
char* begin = string;
13
char tmp;
14
while(begin < end) {
15
tmp = *begin;
16
*begin = *end;
17
*end = tmp;
18
19
begin++;
20
end--;
21
}
22
}
Copied!
Test
1
int main() {
2
3
char test[100] = "abcdefg";
4
printf("sting: %s\n", test);
5
reverse(test);
6
printf("reverse: %s\n", test);
7
return 0;
8
9
}
Copied!
DS with C - Previous
Create a Binary search tree
Next - String and Array
implement strcmp in C
Last modified
5mo ago
Copy link
Contents
Explanation
C version