#pragma once
#include <iostream>
#include <stdio.h>
#include <string.h>
using namespace std;
void reverseString(char* s) {
size_t size = strlen(s);
char temp;
for (size_t i = 0; i < size / 2; i++) {
temp = s[i];
s[i] = s[(size - 1) - i];
s[(size - 1) - i] = temp;
}
}
int main(void) {
char s0[] = "ABCDEF 123 apple"; // 총 16글자 (공백까지 포함하여, 16바이트)
// 문자열 순서 거꾸로 뒤집기
reverseString(s0);
// 뒤집어진 문자열 출력
printf("%s\n", s0);
// 출력 결과: elppa 321 FEDCBA
// 문자열 단어 단위로 뒤집기
char s[] = "This is a test.";
char* word;
char* dummy = NULL;
word = strtok_s(s, " ", &dummy); // word 에 첫 단어 This 가 들어감
while (word != NULL) {
reverseString(word);
printf("%s ", word);
word = strtok_s(NULL, " ", &dummy);
}
int d = 0;
cin >> d;
return 0;
}