I am trying to read some data from a text file, and place it into a structure. The text file consists of an integer number followed by two strings. Written in "columns", for example:
12 qwert yuiop
13 asdfg hjkl
I wanted to create a new structure for each line of data. But I have been getting a core dump error unless I hard code numbers into the new object. What am I doing wrong?.. and is there also a way to keep the structures after they fall out of scope of the while(!data.eof())
Line 24: memory leak here: You are creating completely new array (losing all old data in process) and do not delete old (leaking memory)
Line 26-32: Out of bound access — Array of size i holds values from 0 to i-1.
Line 21: Use of eof usually leads to errors.
I thought I'd repost before you deleted it as you did previously. Please do not delete your posts.
@coal
I am trying to read some data from a text file, and place it into a structure. The text file consists of an integer number followed by two strings. Written in "columns", for example:
12 qwert yuiop
13 asdfg hjkl
I wanted to create a new structure for each line of data. But I have been getting a core dump error unless I hard code numbers into the new object. What am I doing wrong?.. and is there also a way to keep the structures after they fall out of scope of the while(!data.eof())