|
컴파일러가 잘 알려주는데요.
Lvalue required.
대입 operator 의 좌측에는 주소를 가진 변수가 와야지 상수가 오면 안됩니다.
책에 코드가 정말 TARGSIZE = 1 이렇게 나와있다면 해당 저자에게 따져보셔야겠네요.
카니팡...... 님이 쓰신 글 :
: 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;
: }
|