- #1
missfangula
- 32
- 0
Hello,
In my computational science class I have the task of taking the following input file and manipulating it.
I have the following input file:
C1 0 0.00 0 000.0 0 000.0
O2 1 1.22 0 000.0 0 000.0
H3 1 1.09 2 120.0 0 000.0
C4 1 1.54 2 120.0 3 180.0
H5 4 1.09 1 110.0 2 000.0
H6 4 1.09 1 110.0 2 120.0
H7 4 1.09 1 110.0 2 -120.0
stored as input.txt. I need to open this file, read each line, and store each line as an element in an array. Is this even possible in C? I am used to Java, where I could have stored each line as a string object, but in C I have no idea.
After that , I need to be able to access each element in this array, open an element, and tokenize it by space delimiter.
Can someone please show me a code example of how this is done? I have spent several days browsing the internet looking for help in how this works, but I have had no such success. I'm really demoralized right now.
Thank you,
miss fangula
In my computational science class I have the task of taking the following input file and manipulating it.
I have the following input file:
C1 0 0.00 0 000.0 0 000.0
O2 1 1.22 0 000.0 0 000.0
H3 1 1.09 2 120.0 0 000.0
C4 1 1.54 2 120.0 3 180.0
H5 4 1.09 1 110.0 2 000.0
H6 4 1.09 1 110.0 2 120.0
H7 4 1.09 1 110.0 2 -120.0
stored as input.txt. I need to open this file, read each line, and store each line as an element in an array. Is this even possible in C? I am used to Java, where I could have stored each line as a string object, but in C I have no idea.
After that , I need to be able to access each element in this array, open an element, and tokenize it by space delimiter.
Can someone please show me a code example of how this is done? I have spent several days browsing the internet looking for help in how this works, but I have had no such success. I'm really demoralized right now.
Thank you,
miss fangula