speciallop.blogg.se

C find word in file
C find word in file










c find word in file

Use assert to stop the program if the extension of tileName is not "txt" Display an appropriate error Test your function on the file test.txt" given in Part (a). The new file should be called nana Duplicated.txt. as a string, file Name is of the form nane.txt, for some string nane. This function assumes that extension of file is "txt", i.e. Implement the function duplicateLine(fileNane), which given a string tileName, opens the file name fileNane for reading and creates a new file whose content is like fileNane but with all lines duplicated. Test programa: Output: print (wordSearch("test.txt", "Programming"> print (wordSearch("test.txt","programming"> 3 c) Duplicate lines.

C find word in file free#

Feel free to the membership test operator in for strings Test it on the file "test.txt" given in Part (a). If found, it should retum the line number of the first occurrence. Implement the function wordSearch (fileName, word), which given a string fileName and a string word (not containing the new line character), searches for word in the file named tileName. This is a variation of Part (a) which requires reading the file line by line. For example, to find files with instances of the word abstract followed by the. Implement the function in ordin11a(fileName, word), which given a string filean and a string word, checks whether or not word is in that file named #11ac (Hint: Read the file in single shot into a strings and feel free to it that the membership test operator in word in ) Test it on the file named "test.txt" consisting of This is a test for Problem 3 of Programming Assignment 4 Output : Test program: print (1sWord InF11e("test.txt", "Programming")) print(1sWord InF11e("test.txt", "programming"> True False 3 b) Find word in text file: return line number.












C find word in file