$29
CSE 102 Homework Assignment 3
Description • This assignment is about simple file read/write, array usage and string operations. You can use pointers and functions. You cannot use dynamical memory allocation. You cannot use recursion. You can use global variables. You can use standard string library operations. This is a C Programming assignment. You will write a C program according to the following description. • You are given a file(input1.txt) which contains a list of words(one word at a line). • You are given a file(input2.txt) which contains lines of character strings of various sizes. • Your program should read the given files (input1.txt and input2.txt) and for each word in input1.txt, find the location and the orientation in input2.txt. • Strings can appear vertically or horizontally. Once all the strings are found, your program should write their head position and the orientation to output.txt file. • The order of words in input1.txt and output.txt should match. (Ignore the missing words) • Some words may be missing in input2.txt. output.txt should not include the missing words.
Example Contents of input1.txt: Xanthos Patara Myra Adana Arycanda Phaselis Contents of input2.txt: askjdkdanmowflfkadkjkaksdklskksadllasd fkfklsal;sdlslfsdkdfkMyraslfsfeokdlasdfdf wfewfPsdflsdfklsdosfkeowkfweofkwoefkkfsf sdfsdakjewofksdfoiwefjowefks;dfPhaselissdfkefowefjksdlfjslfjsldfj oefkwtifjslflsdfkjeifjsl;asldkiefjiefjlskfdjeifjksk sdlfkawioAjksdlfkeifsflkefjiwfejsllfjeighghj;wp dfkjerwfjr;s;dlskfjfiefwflwekfjwlefiehgwefjiw sdfkkafwXanthosdkfjlsAfdjiefeiwowefwefiefjowiefehgl;lewofjefw iieoefnFGSAiejfiwefjhrwefiiwejfiwjefihhwefklskdf skkfjwifjwiiwifieifwfy[pwpfjwifwefijijwhi] sdfijwiefjiwhiwiejfiwcifjweofi;aiajdijeifwuiefhwoeifjowehi iiwefiwefjwiefjwiefjiajiefiiwejflkajsdlkjfiewhfiwefjowiefhhaskjlskdfu iwjefijefmmiewifjweifnklksjdiaifwefpwefijfiwfOWOEFIEWfnweiuf jfnwefiwfpwfjiejfiwefdjwflljfwiefjiwefwflijijfiewfhu kkfiefiewpfkfjfjhewfoawefkwoefoejwfowoefkowefkowo output.txt: Xanthos (8,9) Horizontal Patara (3,6) Vertical
1
Myra (2,22) Horizontal Arycanda (8,22) Vertical Phaselis (4,32) Horizontal
Remarks: • For input2.txt, strings which correspond to rows are separated by whitespace. • For input2.txt, Maximum length of each row is 250 • For input2.txt, Maximum number of rows is 100 • Position indices start from 1. • For input1.txt, there is no limit on the number of words. • For input1.txt, maximum word length is 10 characters. • You don’t have to do error checking on the input file. You can safely assume that you will be given a proper input file which doesn’t violate the described format. • Be careful with the size of the array you allocate in program stack. Large arrays may not fit in program stack(stack size may be smaller on the test machine) and your program crashes. • Make sure you can read input files with or without a tailing newline at the end. (If you are using a windows machine, newline is CRLF, on unix it is LF). You can alter this using advanced editors (i.e. Visual Studio Code). Test your code for every possible combination. • Do not print anything other than the expected output. (For this assignment, your program prints NOTHING). • You cannot use anything which is not covered in class. • Do not submit any of the files you used for testing. • Do not submit your output file.
Turn in: • Source code of a complete C program. Name of the file should be in this format: <full_name_<id.c. • Example: gokhan_kaya_000000.c. Please do not use any Turkish special characters. • You don’t need to use an IDE for this assignment. Your code will be compiled and run in a command window. • Your code will be compiled and tested on a Linux machine(Ubuntu). GCC will be used. • Make sure you don’t get compile errors when you issue this command : gcc <full_name_<id.c. • A script will be used in order to check the correctness of your results. So, be careful not to violate the expected output format. • Provide comments unless you are not interested in partial credit. (If I cannot easily understand your design, you may loose points.) • You may not get full credit if your implementation contradicts with the statements in this document.