Thứ Hai, 7 tháng 4, 2014
Thứ Bảy, 5 tháng 4, 2014
Bài tập cấu trúc (Phân số)
Ví dụ : Cho một mảng các phân số (PHANSO) gồm n phần tử (n≤50). Hãy viết chương trình nhập và xuất danh sách các phân số sau đó tìm phân số có giá trị lớn nhất, tổng và tích các phân số và nghịch đảo giá trị các phân số trong mảng.
Giải:
#define MAX 100
typedef struct PHANSO
{
int tu, mau;
};
void NhapPS(PHANSO &ps);
void XuatPS(PHANSO ps);
void NhapMangPS(PHANSO dsps[], int &n);
void XuatMangPS(PHANSO dsps[], int n);
PHANSO TimMax(PHANSO dsps[], int n);
int KiemTra(PHANSO ps);
//Tra ve 1: Neu hop le
int USCLN(int a, int b);
PHANSO RutGon(PHANSO ps);
PHANSO NghichDao(PHANSO ps);
PHANSO Nhan(PHANSO ps1, PHANSO ps2);
PHANSO Chia(PHANSO ps1, PHANSO ps2);
PHANSO Tru(PHANSO ps1, PHANSO ps2);
PHANSO Cong(PHANSO ps1, PHANSO ps2);
int SoSanh(PHANSO ps1, PHANSO ps2);
//Tra ve 0: ps1=ps2
//Tra ve 1: ps1>ps2
//Tra ve -1: ps1<ps2
PHANSO TongCacPS(PHANSO dsps[], int n);
PHANSO TichCacPS(PHANSO dsps[], int n);
void NghichDaoCacPS(PHANSO dsps[], int n);
void main()
{
int n;
PHANSO a[MAX], max, s, p;
clrscr();
NhapMangPS(a, n);
printf("\nMang cac phan so vua nhap: ");
XuatMangPS(a, n);
max=TimMax(a, n);
printf("\nPhan so co gia tri lon nhat: ");
XuatPS(max);
s=TongCacPS(a, n);
printf("\nTong gia tri cac phan so co trong mang: ");
XuatPS(s);
p=TichCacPS(a, n);
printf("\nTich gia tri cac phan so co trong mang: ");
XuatPS(p);
NghichDaoCacPS(a, n);
printf("\nMang phan so sau khi nghich dao cac phan tu: ");
XuatMangPS(a, n);
getch();
}
void NhapPS(PHANSO &ps)
{
do
{
printf("\nNhap tu so: ");
scanf("%d", &ps.tu);
printf("\nNhap mau so: ");
scanf("%d", &ps.mau);
if(!KiemTra(ps))
printf("\nMau so khong duoc bang 0, nhap lai phan so\n");
else
break;
} while(1);
ps=RutGon(ps);
}
void XuatPS(PHANSO ps)
{
printf("%d", ps.tu);
if(ps.tu&&ps.mau!=1)
printf("/%d", ps.mau);
}
void NhapMangPS(PHANSO dsps[], int &n)
{
printf("\nNhap so luong phan so: ");
scanf("%d", &n);
for(int i=0; i<n; i++)
{
printf("\nNhap vao phan so thu %d: ", i+1);
NhapPS(dsps[i]);
}
}
void XuatMangPS(PHANSO dsps[], int n)
{
for(int i=0; i<n; i++)
{
XuatPS(dsps[i]);
printf("\t");
}
}
int KiemTra(PHANSO ps)
{
if(ps.mau==0)
return 0;
return 1;
}
int USCLN(int a, int b)
{
a=abs(a);
b=abs(b);
while(a!=b)
{
if(a>b)
a=a-b;
else
b=b-a;
}
return a;
}
PHANSO RutGon(PHANSO ps)
{
int us;
if(ps.tu==0)
return ps;
us=USCLN(ps.tu, ps.mau);
ps.tu=ps.tu/us;
ps.mau=ps.mau/us;
return ps;
}
PHANSO NghichDao(PHANSO ps)
{
PHANSO kq;
kq.tu=ps.mau;
kq.mau=ps.tu;
return kq;
}
PHANSO Nhan(PHANSO ps1, PHANSO ps2)
{
PHANSO kq;
kq.tu=ps1.tu*ps2.tu;
kq.mau=ps1.mau*ps2.mau;
kq=RutGon(kq);
return kq;
}
PHANSO Chia(PHANSO ps1, PHANSO ps2)
{
PHANSO kq;
kq=Nhan(ps1, NghichDao(ps2));
return kq;
}
PHANSO Tru(PHANSO ps1, PHANSO ps2)
{
PHANSO kq;
kq.tu=ps1.tu*ps2.mau-ps1.mau*ps2.tu;
kq.mau=ps1.mau*ps2.mau;
kq=RutGon(kq);
return kq;
}
PHANSO Cong(PHANSO ps1, PHANSO ps2)
{
PHANSO kq;
kq.tu=ps1.tu*ps2.mau+ps1.mau*ps2.tu;
kq.mau=ps1.mau*ps2.mau;
kq=RutGon(kq);
return kq;
}
int SoSanh(PHANSO ps1, PHANSO ps2)
{
ps1=RutGon(ps1);
ps2=RutGon(ps2);
if(ps1.tu==ps2.tu&&ps1.mau==ps2.mau)
return 0;
if(ps1.tu*ps2.mau>ps2.tu*ps1.mau)
return 1;
return -1;
}
PHANSO TimMax(PHANSO dsps[], int n)
{
PHANSO max;
max=dsps[0];
for(int i=1; i<n; i++)
if(SoSanh(dsps[i], max)==1)
max=dsps[i];
return max;
}
PHANSO TongCacPS(PHANSO dsps[], int n)
{
PHANSO s=dsps[0];
for(int i=1; i<n; i++)
{
s=Cong(s, dsps[i]);
}
return s;
}
PHANSO TichCacPS(PHANSO dsps[], int n)
{
PHANSO p=dsps[0];
for(int i=1; i<n; i++)
{
p=Nhan(p, dsps[i]);
}
return p;
}
void NghichDaoCacPS(PHANSO dsps[], int n)
{
for(int i=0; i<n; i++)
{
dsps[i]=NghichDao(dsps[i]);
}
}
Giải:
#define MAX 100
typedef struct PHANSO
{
int tu, mau;
};
void NhapPS(PHANSO &ps);
void XuatPS(PHANSO ps);
void NhapMangPS(PHANSO dsps[], int &n);
void XuatMangPS(PHANSO dsps[], int n);
PHANSO TimMax(PHANSO dsps[], int n);
int KiemTra(PHANSO ps);
//Tra ve 1: Neu hop le
int USCLN(int a, int b);
PHANSO RutGon(PHANSO ps);
PHANSO NghichDao(PHANSO ps);
PHANSO Nhan(PHANSO ps1, PHANSO ps2);
PHANSO Chia(PHANSO ps1, PHANSO ps2);
PHANSO Tru(PHANSO ps1, PHANSO ps2);
PHANSO Cong(PHANSO ps1, PHANSO ps2);
int SoSanh(PHANSO ps1, PHANSO ps2);
//Tra ve 0: ps1=ps2
//Tra ve 1: ps1>ps2
//Tra ve -1: ps1<ps2
PHANSO TongCacPS(PHANSO dsps[], int n);
PHANSO TichCacPS(PHANSO dsps[], int n);
void NghichDaoCacPS(PHANSO dsps[], int n);
void main()
{
int n;
PHANSO a[MAX], max, s, p;
clrscr();
NhapMangPS(a, n);
printf("\nMang cac phan so vua nhap: ");
XuatMangPS(a, n);
max=TimMax(a, n);
printf("\nPhan so co gia tri lon nhat: ");
XuatPS(max);
s=TongCacPS(a, n);
printf("\nTong gia tri cac phan so co trong mang: ");
XuatPS(s);
p=TichCacPS(a, n);
printf("\nTich gia tri cac phan so co trong mang: ");
XuatPS(p);
NghichDaoCacPS(a, n);
printf("\nMang phan so sau khi nghich dao cac phan tu: ");
XuatMangPS(a, n);
getch();
}
void NhapPS(PHANSO &ps)
{
do
{
printf("\nNhap tu so: ");
scanf("%d", &ps.tu);
printf("\nNhap mau so: ");
scanf("%d", &ps.mau);
if(!KiemTra(ps))
printf("\nMau so khong duoc bang 0, nhap lai phan so\n");
else
break;
} while(1);
ps=RutGon(ps);
}
void XuatPS(PHANSO ps)
{
printf("%d", ps.tu);
if(ps.tu&&ps.mau!=1)
printf("/%d", ps.mau);
}
void NhapMangPS(PHANSO dsps[], int &n)
{
printf("\nNhap so luong phan so: ");
scanf("%d", &n);
for(int i=0; i<n; i++)
{
printf("\nNhap vao phan so thu %d: ", i+1);
NhapPS(dsps[i]);
}
}
void XuatMangPS(PHANSO dsps[], int n)
{
for(int i=0; i<n; i++)
{
XuatPS(dsps[i]);
printf("\t");
}
}
int KiemTra(PHANSO ps)
{
if(ps.mau==0)
return 0;
return 1;
}
int USCLN(int a, int b)
{
a=abs(a);
b=abs(b);
while(a!=b)
{
if(a>b)
a=a-b;
else
b=b-a;
}
return a;
}
PHANSO RutGon(PHANSO ps)
{
int us;
if(ps.tu==0)
return ps;
us=USCLN(ps.tu, ps.mau);
ps.tu=ps.tu/us;
ps.mau=ps.mau/us;
return ps;
}
PHANSO NghichDao(PHANSO ps)
{
PHANSO kq;
kq.tu=ps.mau;
kq.mau=ps.tu;
return kq;
}
PHANSO Nhan(PHANSO ps1, PHANSO ps2)
{
PHANSO kq;
kq.tu=ps1.tu*ps2.tu;
kq.mau=ps1.mau*ps2.mau;
kq=RutGon(kq);
return kq;
}
PHANSO Chia(PHANSO ps1, PHANSO ps2)
{
PHANSO kq;
kq=Nhan(ps1, NghichDao(ps2));
return kq;
}
PHANSO Tru(PHANSO ps1, PHANSO ps2)
{
PHANSO kq;
kq.tu=ps1.tu*ps2.mau-ps1.mau*ps2.tu;
kq.mau=ps1.mau*ps2.mau;
kq=RutGon(kq);
return kq;
}
PHANSO Cong(PHANSO ps1, PHANSO ps2)
{
PHANSO kq;
kq.tu=ps1.tu*ps2.mau+ps1.mau*ps2.tu;
kq.mau=ps1.mau*ps2.mau;
kq=RutGon(kq);
return kq;
}
int SoSanh(PHANSO ps1, PHANSO ps2)
{
ps1=RutGon(ps1);
ps2=RutGon(ps2);
if(ps1.tu==ps2.tu&&ps1.mau==ps2.mau)
return 0;
if(ps1.tu*ps2.mau>ps2.tu*ps1.mau)
return 1;
return -1;
}
PHANSO TimMax(PHANSO dsps[], int n)
{
PHANSO max;
max=dsps[0];
for(int i=1; i<n; i++)
if(SoSanh(dsps[i], max)==1)
max=dsps[i];
return max;
}
PHANSO TongCacPS(PHANSO dsps[], int n)
{
PHANSO s=dsps[0];
for(int i=1; i<n; i++)
{
s=Cong(s, dsps[i]);
}
return s;
}
PHANSO TichCacPS(PHANSO dsps[], int n)
{
PHANSO p=dsps[0];
for(int i=1; i<n; i++)
{
p=Nhan(p, dsps[i]);
}
return p;
}
void NghichDaoCacPS(PHANSO dsps[], int n)
{
for(int i=0; i<n; i++)
{
dsps[i]=NghichDao(dsps[i]);
}
}
Các hàm trong thư viện chuẩn kèm ví dụ
1. In/Out [Completed]
2. String & Character [Completed]
3. Math [Completed]
4. Date & Time [Completed]
5. Memory [Completed]
6. Other standard functions [Completed]
1. In/Out [Completed]
Danh sách các hàm sử dụng In/Out:
1.clearerr
2.fclose
3.feof
4.ferror
5.fflush
6.fgetc
7.fgetpos
8.fgets
9.fopen
10.fprintf
11.fputc
12.fputs
13.fread
14.freopen
15.fscanf
16.fseek
17.fsetpos
18.ftell
19.fwrite
20.getc
21.getchar
22.gets
23.perror
24.printf
25.putc
26.putchar
27.puts
28.remove
29.rename
30.rewind
31.scanf
32.setbuf
33.setvbuf
34.sprintf
35.sscanf
36.tmpfile
37.tmpnam
38.ungetc
39.vprintf, vfprintf, and vsprintf
2. String & Character [Completed]
Danh sách các hàm với String & Character:
1.atof
2.atoi
3.atol
4.isalnum
5.isalpha
6.iscntrl
7.isdigit
8.isgraph
9.islower
10.isprint
11.ispunct
12.isspace
13.isupper
14.isxdigit
15.memchr
16.memcmp
17.memcpy
18.memmove
19.memset
20.strcat
21.strchr
22.strcmp
23.strcoll
24.strcpy
25.strcspn
26.strerror
27.strlen
28.strncat
29.strncmp
30.strncpy
31.strpbrk
32.strrchr
33.strspn
34.strstr
35.strtod
36.strtok
37.strtol
38.strtoul
39.strxfrm
40.tolower
41.toupper
3. Math [Completed]
Các hàm làm việc liên quan đên MATH:
1.abs
2.acos
3.asin
4.tan
5.atan2
6.ceil
7.cos
8.cosh
9.div
10.exp
11.fabs
12.floor
13.fmod
14.frexp
15.labs
16.ldexp
17.ldiv
19.log
20.log10
21.modf
22.pow
23.sin
24.sinh
25.sqrt
26.tan
27.tanh
4. Date & Time [Completed]
Các hàm xử lý Date & time:
1.asctime
2.clock
3.ctime
4.difftime
5.gmtime
6.localtime
7.mktime
8.setlocale
9.strftime
10.time
5. Memory [Completed]
Các hàm sử dụng với Memory:
1. calloc
2. free
3. malloc
4. realloc
6. Other standard functions [Completed]
Danh sách các hàm chuẩn còn lại:
1. abort
2. assert
3. atexit
4. bsearch
5. exit
6. getenv
7. longjmp
8. qsort
9. raise
10. rand
11. setjmp
12. signal
13. srand
14. system
15. va_arg
2. String & Character [Completed]
3. Math [Completed]
4. Date & Time [Completed]
5. Memory [Completed]
6. Other standard functions [Completed]
1. In/Out [Completed]
Danh sách các hàm sử dụng In/Out:
1.clearerr
2.fclose
3.feof
4.ferror
5.fflush
6.fgetc
7.fgetpos
8.fgets
9.fopen
10.fprintf
11.fputc
12.fputs
13.fread
14.freopen
15.fscanf
16.fseek
17.fsetpos
18.ftell
19.fwrite
20.getc
21.getchar
22.gets
23.perror
24.printf
25.putc
26.putchar
27.puts
28.remove
29.rename
30.rewind
31.scanf
32.setbuf
33.setvbuf
34.sprintf
35.sscanf
36.tmpfile
37.tmpnam
38.ungetc
39.vprintf, vfprintf, and vsprintf
2. String & Character [Completed]
Danh sách các hàm với String & Character:
1.atof
2.atoi
3.atol
4.isalnum
5.isalpha
6.iscntrl
7.isdigit
8.isgraph
9.islower
10.isprint
11.ispunct
12.isspace
13.isupper
14.isxdigit
15.memchr
16.memcmp
17.memcpy
18.memmove
19.memset
20.strcat
21.strchr
22.strcmp
23.strcoll
24.strcpy
25.strcspn
26.strerror
27.strlen
28.strncat
29.strncmp
30.strncpy
31.strpbrk
32.strrchr
33.strspn
34.strstr
35.strtod
36.strtok
37.strtol
38.strtoul
39.strxfrm
40.tolower
41.toupper
3. Math [Completed]
Các hàm làm việc liên quan đên MATH:
1.abs
2.acos
3.asin
4.tan
5.atan2
6.ceil
7.cos
8.cosh
9.div
10.exp
11.fabs
12.floor
13.fmod
14.frexp
15.labs
16.ldexp
17.ldiv
19.log
20.log10
21.modf
22.pow
23.sin
24.sinh
25.sqrt
26.tan
27.tanh
4. Date & Time [Completed]
Các hàm xử lý Date & time:
1.asctime
2.clock
3.ctime
4.difftime
5.gmtime
6.localtime
7.mktime
8.setlocale
9.strftime
10.time
5. Memory [Completed]
Các hàm sử dụng với Memory:
1. calloc
2. free
3. malloc
4. realloc
6. Other standard functions [Completed]
Danh sách các hàm chuẩn còn lại:
1. abort
2. assert
3. atexit
4. bsearch
5. exit
6. getenv
7. longjmp
8. qsort
9. raise
10. rand
11. setjmp
12. signal
13. srand
14. system
15. va_arg
Các lỗi thường gặp trong lập trình C
Nguyên tắc sửa lỗi (lỗi / cảnh báo – error / warning (có thể bỏ qua mà không cần sửa, tuy nhiên một số warning nếu không được sửa sẽ làm cho chương trình (CT) chạy không đúng · Kích đôi chuột vào thông báo lỗi để nhảy đến vị trí có lỗi trong chương trình (CT).
· Đọc dòng chứa con trỏ hoặc dòng trên (dưới) để sửa lỗi.
· Nếu không tìm thấy lỗi thì phải dò lỗi từ đầu CT đến dòng chứa con trỏ (có thể là do lỗi ở phần trên của dòng chứa con trỏ chứ không phải ở dòng chứa con trỏ (hoặc dòng trên nó)).
· Các lỗi ngữ nghĩa (CT vẫn thực thi nhưng kết quả sai) trình biên dịch C++ không phát hiện được:
Một số từ English thông dụng trong lập trình
Undeclared : không khai báo
unable: không thể
undefined : không xác định
Incorrectly: ko chính xác
Symbol : biểu tượng
Statement: câu lệnh, khai báo
Parameter: tham số
Argument: đối số
Declaration: kê khai
Terminated: chấm dứt
Syntax : cú pháp
Constant: hằng số
Expression: biểu thức
1. ( expected: thiếu ‘(‘
2. ) expected: thiếu ‘)’
3. , expected: thiếu ‘,’
4. : expected after private: thiếu ‘:’ sau private
5. : expected after protected: thiếu ‘:’ sau protected
6. : expected after public: thiếu ‘:’ sau public
7. < expected: thiếu dấu <
8. { expected:thiếu dấu {
9. } expected: thiếu dấu }
10. Array bounds missing ]: thiếu ‘]’ bao dãy
11. Array must have at least one element: dãy phải có ít nhất một phần tử
12. Array size too large: kích cỡ dãy quá lớn
13. Body already defined for this function: nội dung hàm này đã được viết.
14. Call of nonfunction: tên được gọi không được khai báo như một hàm, do khai báo hàm không chính xác hoặc viết sai tên hàm.
15. Cannot cast from 'type1' to 'type2': không thể ép từ kiểu ‘type1’ đến kiểu 'type2'
16. Cannot convert 'type1' to 'type2': không thể chuyển đổi 'type1' thành 'type2'
17. Cannot modify a const object: không thể thay đổi một đối tượng hằng (const)
18. Cannot overload 'main': không thể định nghĩa chồng hàm main
19. Cannot use tiny or huge memory model with Windows: không thể sử dụng mô hình bộ nhớ tiny hoặc huge với Windows
20. Cannot open such file or directory “***”: không thể mở file hoặc thư mục ***
21. Cannot open “Debug\..” for writting: không thể mở file Debug\.. để ghi (hãyđóng CT đã chạy trước đây để có thể chạy lại CT)
22. Case outside of switch: ‘case’ bên ngoài switch
23. Case statement missing ‘:’: ‘case’ thiếu dấu ‘:’
24. Character constant must be one or two characters long: hằng ký tự chỉ có thể là một ký tự (‘a’) hoặc hai ký tự (‘\n’)
25. Compound statement missing }: thiếu dấu } cho khối lệnh (câu lệnh phức).
26. Constant expression required: dãy phải được khai báo với kích thước là hằng số(thường là do khai báo hằng (#define) không đúng).
27. Constant variable 'variable' must be initialized: biến có kiểu const phải được khởi tạo (vì ta không thể gán giá trị cho biến có kiểu const trong quá trình thi hành CT). Thực hành nhập môn lập trình 10
28. Could not find a match for argument(s): các đối số không phù hợp (kiểm tra lại khai báo hàm và các đối số truyền vào)
29. Could not find file 'filename': không thể tìm file 'filename'
30. Declaration does not specify a tag or an identifier: khai báo (kiểu struct hoặc kiểu union) không chứa thành phần
31. Declaration is not allowed here: không cho phép khai báo ở đây
32. Declaration missing ‘;’: khai báo thiếu dấu ‘;’
33. Declaration syntax error: khai báo sai lỗi cú pháp
34. Declaration terminated incorrectly: kết thúc khai báo không chính xác
35. Declaration was expected: khai báo được mong muốn ở đây nhưng không tìm thấy
36. Default argument value redeclared: giá trị của tham số mặc định bên trong hàm bị thay đổi
37. Default argument value redeclared for parameter 'parameter': giá trị của tham số (đối số) mặc định 'parameter' bên trong hàm bị thay đổi
38. Default expression may not use local variables: một biểu thức tham số (đối số)mặc định bên trong hàm không được phép sử dụng tham số khác
39. Default outside of switch: default bên ngoài switch
40. Default value missing: tham số theo sau một tham số mặc định phải có giá trị mặc định
41. Default value missing following parameter 'parameter': thiếu giá trị mặc định cho tham số 'parameter' (vì nó theo sau một tham số mặc định nên phải có giá trị mặc định)
42. Define directive needs an identifier: khai báo define cần có một tên
43. Delete array size missing ]: thiếu ‘]’ khi hủy một dãy
44. Division by zero: chia cho 0
45. do statement must have while: do phải có while
46. do-while statement missing (: do-while thiếu dấu ‘(’
47. do-while statement missing ): do-while thiếu dấu ‘)’
48. do-while statement missing ;: do-while thiếu dấu ‘;’
49. Duplicate case: mỗi case trong switch phải có giá trị đi kèm
50. Enum syntax error: khai báo kiểu enum sai cú pháp
51. Expression expected: một biểu thức được mong muốn ở đây nhưng ký hiệu hiện thời không thể bắt đầu cho một biểu thức
52. Expression of scalar type expected: mong muốn biểu thức có kiểu vô hướng. Các toán tử !, ++, và – yêu cầu một biểu thức có kiểu vô hướng (char, short, int,long, enum, float, double, long double, pointer)
53. Expression syntax: cú pháp biểu thức
54. File name too long: tên file qúa dài
55. For statement missing ‘(‘: câu lệnh for thiếu ‘(’
56. For statement missing ): câu lệnh for thiếu ‘)’
57. For statement missing ;: câu lệnh for thiếu ‘)’
58. 'function' cannot return a value: hàm không thể trả về giá trị (nó là hàm void)
59. 'function' must be declared with no parameters: hàm phải được khai báo với không tham số
60. 'function' must be declared with one parameter: hàm phải được khai báo với một tham số Thực hành nhập môn lập trình11
61. 'function' must be declared with two paraameters: hàm phải được khai báo với một tham số
62. 'function1' cannot be distinguished from 'function2': không thể phân biệt 'function1' với 'function2'
63. Function 'function' should have a prototype: hàm 'function' nên có tiêu đề.
64. Function call missing ): thiếu dấu ‘)’ khi gọi hàm.
65. Function should return a value: chưa trả về giá trị cho hàm
66. 'identifier' cannot start a parameter declaration: 'identifier' không thể bắt đầu cho khai báo một tham số
67. 'identifier' is not a member of struct: 'identifier' không phải là thành phần của struct
68. 'identifier' is not a non-static member and can't be initialized here: 'identifier' không phải là một biến tĩnh và không thể được khởi tạo ở đây
69. 'identifier' is not a parameter: 'identifier' không phải là một tham số
70. Identifier expected: mong muốn một định danh
71. If statement missing (: câu lệnh if thiếu ‘(‘
72. If statement missing ): câu lệnh if thiếu ‘)‘
73. Illegal character 'character' (0x'value'): hằng ký tự sai
74. Illegal structure operation: toán tử trên struct không đúng (chỉ có thể là: ‘.’, &,=)
75. Illegal use of floating point: toán tử trên số thực chấm động không đúng (chỉ có thể là: SHL, SHR, AND, OR, XOR, NOT, ? :, *, …)
76. Improper use of typedef 'identifier': kiểm tra khai báo 'identifier' ở dòng typedef
77. Incorrect number format: định dạng số không đúng
78. Incorrect use of default: sau default không có dấu ‘:’
79. Invalid use of dot: sử dụng dấu ‘.’ không đúng, ví dụ:
struct foo
{
int x;
int y;
}p = {0,0};
int main (…)
{
p.x++; /* Đúng */
p. y++; /* Sai: Invalid use of dot */
return 0;
}
80. Lvalue required: thành phần bên trái của lệnh gán phải là biến
81. main must have a return type of int: hàm main phải return về kiểu int
82. Misplaced break: break không nằm trong switch hoặc một vòng lặp
83. Misplaced continue: continue không nằm trong một vòng lặp
84. Misplaced else: else không có if
85. Missing *** before yyy: thiếu *** trước yyy
86. Missing function header (old-style): sai tiêu đề ở phần định nghĩa hàm (có thểmthừa dấu ; sau tiêu đề)
87. Multiple declaration for 'identifier': trùng khai báo cho 'identifier'
88. Need an identifer to declare: cần một định danh cho khai báo
89. No : following the ?: không có : sau ? trong cấu trúc tam phân (… ? … : … ) Thực hành nhập môn lập trình 12
90. Not an allowed type: không cho phép kiểu này (chẳng hạn, không thể trả về dữ liệu kiểu mảng tĩnh cho hàm)
91. Numeric constant too large: hằng số quá lớn
92. new line in constant: thiếu dấu ”
93. operator [] missing ]: toán tử [] thiếu ]
94. sizeof may not be applied to a function: toán tử sizeof không thể áp dụng cho hàm
95. Size of 'identifier' is unknown or zero: kích thước của 'identifier' không biết hoặc là 0
96. Size of the type is unknown or zero: kích thước của kiểu không biết hoặc là 0
97. Statement missing ‘;’: thiếu dấu ‘;’
98. Structure size too large: kích thước của struct quá lớn
99. Switch selection expression must be of integral type: biểu thức chọn của switch phải là kiểu nguyên
100. unexpected end of file: thiếu }
101. *** undeclared identifier: thiếu khai báo ***