#include <stdio.h>
#include <string.h>
#include <ctype.h>
int main(){
char input[100], storage[100], max[100];
int start=0;
int k, l;
gets(input);
for( int i=0; i<=strlen(input); i++){
for( int j = 0; j<=99; j++){
storage[j] = '\0';
}
if (input[i] == ' ' || input[i] == '\0'){
for( k = start, l = 0; k < i; k++, l++){
if( ispunct(input[k]) == 0){
storage[l] = input[k];
}
if( k == (i-1) ){
start = i+1;
}
}
}
if( strlen(storage) > strlen(max) ){
for( int q = 0; q<= strlen(storage); q++){
max[q] = storage[q] ;
}
}
}
printf("%s\n",max);
return 0;
}
문장을 입력받고, 가장 긴 단어를 출력하는 프로그램인데,
위에 진한 글씨를 안넣었을때는 프로그램이 안돌아가다,
진한 글씨 부분, \0문자 또는 white space 문자를 찾으면
단어의 길이를 조사하라고 바뀌니까 프로그램이 잘 돌아가는데
\0과 ' ', 즉 null문자와 white space문자가 어떤 차이점이 있나요?
http://stackoverflow.com/questions/3696298/wondering-in-c-strings-null-white-spaces
사이톤=미국 공대40위권다니는 개지잡 도피유학생,영어잘못함