freeseaboy 님의 멋있어 지려 노력하는 블로그
기초 level01 본문
반응형
설명 : 대문자 및 소문자를 입력받아 그역으로 출력하는 프로그램
취약점 : 엄청나다.
등급 : 하
#include <stdio.h>
#include <string.h>
#include <stdbool.h>
#include <ctype.h>
#define __GNU__IS__NOT__UNIX__
#define g_ARRAY_SZ 24
int main(void){
char cl_array[g_ARRAY_SZ] = {0,}; //Create buffer
bool bl_stat_flag = false;
printf("Insert value\n");
scanf("%s",cl_array);
if(g_ARRAY_SZ-1 <= strlen(cl_array)){ //Check value lenght
printf("Buffer over flow\n");
return -1;
}
for(int i=0;i<g_ARRAY_SZ;++i){
if(0x00 == cl_array[i]){ // Check null value
bl_stat_flag = true;
if(0x00 == cl_array[0]){ // Check first null value
printf("First value is null\n");
return -1;
}
break;
}
}
__GNU__IS__NOT__UNIX__
for(int i=0;i<g_ARRAY_SZ;++i){ // Find upper of lower and exange char
if((char)65 <= cl_array[i] && (char)90 >= cl_array[i]){
cl_array[i] = tolower(cl_array[i]);
continue;
}
cl_array[i] = toupper(cl_array[i]);
}
printf("-> %s\n",cl_array);
return 0;
}
반응형
'일상생활 > 심심풀이 개발' 카테고리의 다른 글
리스트 만들기 테스트 (0) | 2025.06.07 |
---|---|
Queue 구현 (0) | 2025.06.06 |
Stack 구현해보기 (0) | 2025.06.03 |
style01.c 로또 추출기 (0) | 2025.06.03 |
기초 level02 개발 영상 (0) | 2025.06.03 |