|
c언어 기초플러스라는 책으로 공부중입니다.
툴은 볼랜드 c++2006 터보익스플로러구요.
근데 밑에 있는 소스가 안됩니다.
책하고 비교해보니 오타도 없는거 같은데 왜 안되는지 궁금합니다.
//strncpy()예제
#include <stdio.h>
#include <string.h>
#define SIZE 40
#define TARGSIZE 7
#define LIM 5
int main(void)
{
char qwords[LIM][TARGSIZE];
char temp[SIZE];
int i = 0;
printf("Enter %d words beginning with q:\n", LIM);
while (i < LIM && gets(temp))
{
if (temp[0] != 'q')
{
printf("%s doesn't begin with q!\n", temp);
}
else
{
strncpy(qwords[i], temp, TARGSIZE = 1);
qwords[i][TARGSIZE = 1] = '\0';
i++;
}
}
puts("Here are the words accepted:");
for(i = 0; i < LIM; i++)
{
puts(qwords[i]);
}
return 0;
}
|