char name[35]; char *new_name;
char first_name[10]; char **parts;
char last_name[20]; float speed;
char *min_name;
Write statements to accomplish the following tasks:
main(int argc, char *argv) {
FILE *input_file;
char buffer[101];
int num_lines;
int price
double quantity;
...
}
Assume that the above program takes two command line arguments. The
first argument is the name of the input file and the second argument is
the number of lines in the file.
int x;
char month[6];
char *string_ptr;
int *int_ptr;
strcpy(month, "febr.");
x = 20;
string_ptr = month;
int_ptr = &x;
*int_ptr = 40;
Also suppose that the above variables are assigned the following
memory layout:
x: 0x600
month: 0x604
string_ptr: 0x60c
int_ptr: 0x610
After the above code executes, what is the value of:
xxxx appears dd timeswhere xxxx is your search word and dd is the number of times it appears in the file. Do not worry about specifying field widths in your print statement.
As an example, suppose main is placed in an executable named search, and you type the command
search words.txt do
if words.txt contains
the following lines:
how do you do
today and how
do
you think you will
do tomorrow?
|
your function should produce the output:
1: 2
2: 0
3: 1
4: 0
5: 1
do appears 4 times
|