코드이해도움요청합니다 자세하게알려주실분
By은지
질문 제목 : 코드에대한 이해주어진 코드에대한이해불가질문 내용 :c언어 같은단어찾고 몆번반복되어있는지 알아내기#include stdio.h
#include string.h /* for strncmp(), etc. */#define min_buf 256 -이것들이 무슨 역할을하는지
#define max_buf 2048char buffer[ max_buf ]; -max,min buf가 무엇을뜻하는지
char word[ min_buf ];
char nextword[ min_buf ]; void parsefile( file * fp, char * fname ) { -이 함수가 무슨성능인지
int rval;
/* read first word */
rval = fscanf( fp, %s, word );
if ( rval != 1 ) {
printf( failed to read first word\n );
exit( -1 );
}int main( int argc, char * argv[] ) { - 이 함수의 의미
int i;
file * fp;
for (i = 1; i argc; i++) {
fp = fopen( argv[ i ], r );
if ( fp == null ) {
printf( could not open file %s\n, argv[ i ] );
exit( -1 );
}
else {
parsefile( fp, argv[ i ] );
fclose( fp );
}
}
return 0;
}
while ( ! feof( fp ) ) { 이 과정에대한 이해
rval = fscanf( fp, %s, nextword );
if ( rval != 1 )
continue;if ( strncmp( word, nextword, min_buf ) == 0 ) {
printf( in file %s, repeated word: %s %s\n,
fname, word, nextword );/* heuristic as to when to print out context info */
/* first letter must be alphabets */if ( isalpha( word[ 0 ] ) ) {
fgets( buffer, max_buf, fp );
printf( context: %s\n, buffer );
printf( re-run program after fixing!!!\n );
}
}
strncpy( word, nextword, min_buf );python을 하다가 와서그런지 하나도 이해가안되네요..
자세하게 알려주시면 감사하겠습니다
-
인1형녀
C언어 강좌 3시간정도만 흝어보세요.
그리고 필요한거 하나하나 검색해거시면 이해되실거예요.
포인터 빼고. -
도리도리
그냥 C언어를 공부하세요
기본이라도 알아야;; -
레이
다른언어하셨으면 조금만 노력하시면 될텐데..