![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#31 |
|
Programming Guru
![]() Join Date: Oct 2004
Location: namespace std
Posts: 1,246
Rep Power: 5
![]() |
the "simple" solution in post 5 (after unfucking it so it would compile) still truncates everything after a space.
edit: never mind, i forgot the thread spanned two pages and my statement is redundant.
__________________
i put on my robe and wizard hat... Have you ever heard of Plato, Aristotle, Socrates?...Morons. |
|
|
|
|
|
#32 |
|
Resident Grouch
![]() ![]() ![]() ![]() ![]() ![]() Join Date: Jun 2005
Posts: 6,453
Rep Power: 10
![]() |
To specifically answer post #29: You didn't read my previous post. One can pass a C++ string into a C-string situation by passing ElStringo.c_str (). The c_str () method represents the string as a C string. It is readable, not writable.
__________________
Abstraction doesn't make it impossible to write bad code; it makes it possible to write superior code. Contributor's Corner: Grumpy on C++ Exceptions DaWei on Pointers |
|
|
|
|
|
#33 | |
|
Newbie
Join Date: Nov 2005
Posts: 23
Rep Power: 0
![]() |
Quote:
Now..., how do I get that 'string' function to work? The <STRING.H> is recognized, but it says 'string' is undefined symbol.
__________________
Magius Avvail Genocidal Studios™ Administrator Pasadena, Texas 77502 Compiler: Turbo C++ Compiler: (sometimes) Dev/Borland C++ Programmer Status: Somewhat of a Newb. |
|
|
|
|
|
|
#34 |
|
Resident Grouch
![]() ![]() ![]() ![]() ![]() ![]() Join Date: Jun 2005
Posts: 6,453
Rep Power: 10
![]() |
Ahhh, bit by schlock, after all. <string.h> and <string> aren't equivalents.
__________________
Abstraction doesn't make it impossible to write bad code; it makes it possible to write superior code. Contributor's Corner: Grumpy on C++ Exceptions DaWei on Pointers |
|
|
|
|
|
#35 | |
|
Newbie
Join Date: Nov 2005
Posts: 23
Rep Power: 0
![]() |
Quote:
__________________
Magius Avvail Genocidal Studios™ Administrator Pasadena, Texas 77502 Compiler: Turbo C++ Compiler: (sometimes) Dev/Borland C++ Programmer Status: Somewhat of a Newb. |
|
|
|
|
|
|
#36 | |
|
Resident Grouch
![]() ![]() ![]() ![]() ![]() ![]() Join Date: Jun 2005
Posts: 6,453
Rep Power: 10
![]() |
Quote:
__________________
Abstraction doesn't make it impossible to write bad code; it makes it possible to write superior code. Contributor's Corner: Grumpy on C++ Exceptions DaWei on Pointers |
|
|
|
|
|
|
#37 | |
|
Newbie
Join Date: Nov 2005
Posts: 23
Rep Power: 0
![]() |
Quote:
Awkward enough, my friend recites that latter comment quite a bit... *is now suspicious* Anyway, seriously, now. Which header do I use to enable the 'string' function? ![]()
__________________
Magius Avvail Genocidal Studios™ Administrator Pasadena, Texas 77502 Compiler: Turbo C++ Compiler: (sometimes) Dev/Borland C++ Programmer Status: Somewhat of a Newb. |
|
|
|
|
|
|
#38 | |
|
Caffeinated Neural Net
Join Date: Jun 2005
Location: Dry west coast of Canada
Posts: 929
Rep Power: 4
![]() |
Quote:
I believe old Borland compilers (I have BC++ 3.1 somewhere) used the header file <string.h> and the class was called String (note the capital), but I might be wrong. Of course, even if I'm right, I don't know what methods the old version of the class supports. You really should try to convince your teacher/IT staff/whoever that it's safe and worthwhile. Let them know that it's possible to obtain software that is free, legal, and safe, and that this will benefit any students learning to program. Let them virus-scan the installation files if this will make them feel better. It's my opinion that any computer lab used for teaching programming should have suitable tools available, and if they don't, the students should lobby for such tools. Failing that, I believe resorting to subterfuge is appropriate. Bring in disks without being seen, or burn a CD and tell them it's music that you'd like to listen to while you work on your assignments after school (having music as well as the compiler would make sense).
__________________
A man's knowledge is like an expanding sphere, the surface corresponding to the boundary between the known and the unknown. As the sphere grows, so does its surface; the more a man learns, the more he realizes how much he does not know. Hence, the most ignorant man thinks he knows it all. - L. Sprague de Camp |
|
|
|
|
|
|
#39 |
|
Newbie
Join Date: Nov 2005
Posts: 23
Rep Power: 0
![]() |
Right..., right... I get it now. That blows...
![]()
__________________
Magius Avvail Genocidal Studios™ Administrator Pasadena, Texas 77502 Compiler: Turbo C++ Compiler: (sometimes) Dev/Borland C++ Programmer Status: Somewhat of a Newb. |
|
|
|
|
|
#40 | |
|
Programmer
Join Date: Mar 2005
Posts: 40
Rep Power: 0
![]() |
Quote:
Well, There's no header in Turbo C++ 3.1 which can "enable" or "provide" you string function (or class ...or whatever you want to say it...) Although there are some way you have in Turbo C++ to input a full string. The simplest you'd find is: char *str; str = new char; // for avoiding comipler runtime errors cin >> str; But it'll ignore everything after the whitespace(after you hit spacebar while entering a string). To overcome this problem, try any of the below listed suggestions: Through getline(): cin.getline(str); cin.getline ( str, sizeof(str), '\n'); Through get(): cin.get( str, sizeof(str) ); cin.get( str, sizeof(str), '\n' ); Through read(): cin.read( str, sizeof(str) ); |
|
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|