Hello guys, I need help:
Let's say that in a txt file named hot.txt, I have this: 12,23,32
And with ifstream I want to take those number, adding one by one as integers in a linked list.
I know this part is quite wrong that why Im asking for help:
1 2 3
myList.get(x,256,','); // dafaq
int num=atoi(x);
list->addOrdered(num);
What I wanted to do is to stop before each comma and take that character and store it in the linked list and continue until the end of the file, but I couldnt.
p is a pointer to a single char. If you enter "hot.txt\n" for line 4, you will exceed the bounds of the memory you allocated, causing undefined behavior and bad things will happen. You have the same issue with x.
Cire, but if I put cin>>*p, it gives em an error!
And also with *x, I wont read any number D:
I didn't suggest that cin >>*p was the solution to your problems.
p points to a single char. You need it to point to more than a single char. Manipulating your single char, whether it is *p or *x is not going to get you the results you're looking for.
Presumably you're familiar with arrays. Use them. Or better yet, use std::string.