Can anyone tell me how can I do this?
fgetc() function in C fgetc() function is a file handling function in C programming language which is used to read a character from a file. It reads single character at a time and moves the file pointer position to the next address/location to read the next character.
Individual characters in a string can be accessed by specifying the string name followed by a number in square brackets ( [] ). String indexing in Python is zero-based: the first character in the string has index 0 , the next has index 1 , and so on.
We can use java.io.BufferedReader readLine() method to read file line by line to String. This method returns null when end of file is reached. Below is a simple program showing example for java read file line by line using BufferedReader.
with open(filename) as f:   while True:     c = f.read(1)     if not c:       print "End of file"       break     print "Read a character:", c 
                        First, open a file:
with open("filename") as fileobj:     for line in fileobj:          for ch in line:             print(ch)  This goes through every line in the file and then every character in that line.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With