Question
The goal of this is to get practice writing code in C which uses some standard library functions and some advanced file I/O Please provide
The goal of this is to get practice writing code in C which uses some standard library functions and some advanced file I/O
Please provide a main function that demonstrates their use and any testing data files you use.
1. int countOccurrences (const char* filename, const int target) (15 points)
The function takes a file name and an integer as arguments. The file contains a bunch of whitespace-delimited integers. Complete the body of the function so that it returns the number of times target occurs in the file. For instance, if target is 12 and the file contains
34 7 8 129
12 2
12 -8 12 4
then the function should return 3.
2. int copyFile(const char* src_file, const char* dest_file) (15 points)
The function takes two file names as arguments. The function should copy all the data from src_file into dest_file.
In main, be sure to defend against buffer overflow attacks! No file name should be over 15 characters long, including the file extension!
Further, be sure to follow proper error handling routines (null checks etc)
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started