this error occur when compile

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

this error occur when compile

panjapol28@Punn:~/a2$ gcc -Wall -W -pedantic -o unscramble unscramble.c
unscramble.c: In function 'read_dictionary':
unscramble.c:24:27: warning: comparison of integer expressions of different signedness: 'int' and 'size_t' {aka 'long unsigned int'} [-Wsign-compare]
24 |
for (int i = 0; i < strlen(word); i++) {
A
unscramble.c: In function 'unscramble_word':
unscramble.c:43:45: warning: passing argument 4 of 'qsort' from incompatible pointer type [-Wincompatible-pointer-types] 43 | qsort (word, strlen(word), sizeof(char), &strcmp);
839
int (*) (const char *, const char *)
In file included from unscramble.c:2:
/usr/include/stdlib.h:839:34: note: expected '__compar_fn_t' {aka ‘int (*)(const void *, const void *)'} but argument is of type 'int (*)(const char *, const char *)'
__compar_fn_t__compar) __nonnull ((1, 4));
ANNNNNNN
unscramble.c:50:63: warning: passing argument 4 of 'qsort' from incompatible pointer type [-Wincompatible-pointer-types] 50 |
839
93
In file included from unscramble.c:2:
/usr/include/stdlib.h:839:34: note: expected ' *__compar_fn_t' {aka ‘int (*)(const void *, const void *)'} but argument is of type 'int (*)(const char *, const char *)'
__compar_fn_t __compar) __nonnull ((1, 4));
'~~~~~~~
97
~~~~~~V
له لم له لم له لم ۸
unscramble.c: In function 'main':
unscramble.c:93:75: error: 'char_cmp' undeclared (first use in this function)
]
124 | fclose(dict_file);
qsort (sorted_jumbled_word, strlen(sorted_jumbled_word), sizeof(char), char_cmp);
A~~~~~~~
unscramble.c:93:75: note: each undeclared identifier is reported only once for each function it appears in
unscramble.c:97:25: error: 'num_words' undeclared (first use in this function)
for (int i = 0; i < num_words; i++) {
ANNNNNI
unscramble.c:100:36: error: 'dictionary' undeclared (first use in this function); did you mean 'read_dictionary'?
100 |
strcpy(sorted_dict_word, *(dictionary + i));
^~~~~~~~~~
~~~~~~~~V
~~~~~~,
یم بہ یم بہ یم بہ یہ ا
int (*) (const char *, const char *)
read_dictionary
unscramble.c:124:8: warning: passing argument 1 of 'fclose' from incompatible pointer type [-Wincompatible-pointer-type
char *
In file included from unscramble.c:1:
~~~~~~^~~~~~~~
/usr/include/stdio.h:178:26: note: expected 'FILE *' but argument is of type 'char *'
178 | extern int fclose (FILE *__stream);
unscramble.c:131:5: error: expected declaration or statement at end of input
131 |
}
A
qsort (sorted_word, strlen(sorted_word), sizeof(char), &strcmp);
unscramble.c:67:11: warning: unused variable 'jumbles_file' [-Wunused-variable]
67 | char* jumbles_file = *(argv + 2);
panjapol28@Punn:~/a2$ |
Transcribed Image Text:panjapol28@Punn:~/a2$ gcc -Wall -W -pedantic -o unscramble unscramble.c unscramble.c: In function 'read_dictionary': unscramble.c:24:27: warning: comparison of integer expressions of different signedness: 'int' and 'size_t' {aka 'long unsigned int'} [-Wsign-compare] 24 | for (int i = 0; i < strlen(word); i++) { A unscramble.c: In function 'unscramble_word': unscramble.c:43:45: warning: passing argument 4 of 'qsort' from incompatible pointer type [-Wincompatible-pointer-types] 43 | qsort (word, strlen(word), sizeof(char), &strcmp); 839 int (*) (const char *, const char *) In file included from unscramble.c:2: /usr/include/stdlib.h:839:34: note: expected '__compar_fn_t' {aka ‘int (*)(const void *, const void *)'} but argument is of type 'int (*)(const char *, const char *)' __compar_fn_t__compar) __nonnull ((1, 4)); ANNNNNNN unscramble.c:50:63: warning: passing argument 4 of 'qsort' from incompatible pointer type [-Wincompatible-pointer-types] 50 | 839 93 In file included from unscramble.c:2: /usr/include/stdlib.h:839:34: note: expected ' *__compar_fn_t' {aka ‘int (*)(const void *, const void *)'} but argument is of type 'int (*)(const char *, const char *)' __compar_fn_t __compar) __nonnull ((1, 4)); '~~~~~~~ 97 ~~~~~~V له لم له لم له لم ۸ unscramble.c: In function 'main': unscramble.c:93:75: error: 'char_cmp' undeclared (first use in this function) ] 124 | fclose(dict_file); qsort (sorted_jumbled_word, strlen(sorted_jumbled_word), sizeof(char), char_cmp); A~~~~~~~ unscramble.c:93:75: note: each undeclared identifier is reported only once for each function it appears in unscramble.c:97:25: error: 'num_words' undeclared (first use in this function) for (int i = 0; i < num_words; i++) { ANNNNNI unscramble.c:100:36: error: 'dictionary' undeclared (first use in this function); did you mean 'read_dictionary'? 100 | strcpy(sorted_dict_word, *(dictionary + i)); ^~~~~~~~~~ ~~~~~~~~V ~~~~~~, یم بہ یم بہ یم بہ یہ ا int (*) (const char *, const char *) read_dictionary unscramble.c:124:8: warning: passing argument 1 of 'fclose' from incompatible pointer type [-Wincompatible-pointer-type char * In file included from unscramble.c:1: ~~~~~~^~~~~~~~ /usr/include/stdio.h:178:26: note: expected 'FILE *' but argument is of type 'char *' 178 | extern int fclose (FILE *__stream); unscramble.c:131:5: error: expected declaration or statement at end of input 131 | } A qsort (sorted_word, strlen(sorted_word), sizeof(char), &strcmp); unscramble.c:67:11: warning: unused variable 'jumbles_file' [-Wunused-variable] 67 | char* jumbles_file = *(argv + 2); panjapol28@Punn:~/a2$ |
Expert Solution
steps

Step by step

Solved in 2 steps

Blurred answer
Knowledge Booster
Function Arguments
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education