$: cd /home/cs/zhengli/cs480-02
$: ls
data.zip zero.zip
$: cp *.zip /home/cs/zhengli/cssc1710/programming
$: cd /home/cs/zhengli/cssc1710/programming
$: ls
data.zip zero.zip
$: scp cssc1710@edoras.sdsu.edu:/home/cs/zhengli/cssc1710/localpull/project.tar.gz ./
$: tar -xzvf project.tar.gz
$: unzip data.zip, zero.zip
$: rm project.tar.gz
$: zip -r project.zip programming
$: scp /home/eddie/workplace/cs480/prelimproj.zip cssc1710@edoras.sdsu.edu:~/programming
/* * The main function will contain the following steps: */
int main(void) { // 1. Fork the first child process. // If we're in the child process: // 1.1 Print a message indicating that this child is starting the `testalphabet` program. // 1.2 Use exec (or a variant like execl, execv, execle, etc.) to replace the current process image with the `testalphabet` program. // If we're in the parent process: // 1.3 Do nothing, allowing the parent process to continue to the next step.
// 2. Fork the second child process. // If we're in the child process: // 2.1 Print a message indicating that this child is starting the `testspecial` program. // 2.2 Use exec (or a variant like execl, execv, execle, etc.) to replace the current process image with the `testspecial` program. // If we're in the parent process: // 2.3 Do nothing, allowing the parent process to continue to the next step.
// 3. Wait for the first child process to finish. // 3.1 Print a message indicating that the first child process has finished the `testalphabet` program.
// 4. Wait for the second child process to finish. // 4.1 Print a message indicating that the second child process has finished the `testspecial` program.
// 5. End the program. }
eddie@eddie-pcmasterrace:~/workplace/cs480/programming/one$ ./mulproc CHILD <15307> process has started executing testalphabet program! CHILD <15308> process has started executing testspecial program! a -> 2973036 b -> 556908 c -> 765864 d -> 1786752 e -> 4883076 f -> 765336 g -> 809292 h -> 2818068 i -> 2586276 j -> 35112 k -> 401412 l -> 1728276 m -> 1050852 n -> 2509320 o -> 2766192 p -> 562848 q -> 28776 r -> 2177076 s -> 2465496 t -> 3291684 u -> 1015608 v -> 276804 w -> 1085040 x -> 46860 y -> 730752 z -> 12936 CHILD <15307> process has finished with testalphabet program! , -> 745668 . -> 798072 : -> 15708 ; -> 32340 ! -> 63228 CHILD <15308> process has finished with testspecial program!
#include <stdio.h> #include "count.h"
void specialcharcount(char *path, char *filetowrite, long charfreq[]) { // Define the special characters to count. // Open the directory specified by the 'path' parameter. // If the directory cannot be opened, return.
// For each file in the directory: // Check if the file has a .txt extension by comparing the last 4 characters of the filename to ".txt". // If it is a .txt file, construct the full file path and open the file. // If the file cannot be opened, continue to the next file. // For each character in the file: // Iterate over the list of special characters. // If the character matches a special character, increment the corresponding element in the 'charfreq' array. // Close the file.
// Open the output file specified by the 'filetowrite' parameter. // If the file cannot be opened, return. // Write the 'charfreq' array to the output file in the format "character -> frequency". // Close the output file and the directory. }
#include <stdio.h> #include "count.h"
void alphabetlettercount(char *path, char *filetowrite, long alphabetfreq[]) { // Open the directory specified by the 'path' parameter. // If the directory cannot be opened, return.
// For each file in the directory: // Check if the file has a .txt extension by comparing the last 4 characters of the filename to ".txt". // If it is a .txt file, construct the full file path and open the file. // If the file cannot be opened, continue to the next file. // For each character in the file: // Check if the character is an alphabet letter. // If it is, convert it to lowercase using the 'tolower' function and increment the corresponding element in the 'alphabetfreq' array. // Close the file.
// Open the output file specified by the 'filetowrite' parameter. // If the file cannot be opened, return. // Write the 'alphabetfreq' array to the output file in the format "letter -> frequency". // Close the output file and the directory. }