I need to read in a line, but the problem is getline requires a size. So how could I get it to read a line when the situation is: char *txt and the size is not known.
I probably need to overload the operator>> but how??? I dont know the size.
If you are using char* txt, you must allocate space for the string. You can do this either using new or on the stack (e.g. char txt;). Once you have allocated space for your string, then that is the number you pass to getline, because that is the maximum number of characters that your string can hold.
By the way, the standard string class is in my opinion easier to use than char* style strings. With those, you don't have to allocate space or pay attention to maximum characters that will fit.
>char *txt and the size is not known.
Change char * to std::string and use getline. :)
getline ( in, txt );
borland 4.5 does not allow the use of non .h libraries :( so I am stuck...I have just recently installed .net at home but because I have never used it before, I dont know how to compile on it.
>borland 4.5 does not allow the use of non .h libraries
Borland offers their 5.5 version for free download. If this is your choice then upgrade. If it's not your choice then b1tchslap the person making the decisions and tell them to upgrade.
>so I am stuck...
No, you just have to do it the hard way. Use a fixed size buffer and read until it's full, copying into a dynamic array. Then resize the array and do the same thing. Repeat until you have the entire string. This method is awkward, bloated and unsafe, but it works if you have the time to debug it.
>I dont know how to compile on it.
My copy of VC++.NET came with a manual, how about yours?
p.s. "I am silly"? That's about the dumbest censor replacement I've ever seen. :rolleyes: