Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Nov 29th, 2005, 2:13 AM   #31
bl00dninja
Programming Guru
 
bl00dninja's Avatar
 
Join Date: Oct 2004
Location: namespace std
Posts: 1,246
Rep Power: 5 bl00dninja is on a distinguished road
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.
bl00dninja is offline   Reply With Quote
Old Nov 29th, 2005, 6:23 AM   #32
DaWei
Resident Grouch
 
DaWei's Avatar
 
Join Date: Jun 2005
Posts: 6,453
Rep Power: 10 DaWei is on a distinguished road
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
DaWei is offline   Reply With Quote
Old Nov 29th, 2005, 8:01 AM   #33
Magius Avvail
Newbie
 
Magius Avvail's Avatar
 
Join Date: Nov 2005
Posts: 23
Rep Power: 0 Magius Avvail is an unknown quantity at this point
Quote:
Originally Posted by DaWei
Then piss-poor practices won't hurt you at all. Unless they spread to other areas, of course.
Of course!

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.
Magius Avvail is offline   Reply With Quote
Old Nov 29th, 2005, 8:16 AM   #34
DaWei
Resident Grouch
 
DaWei's Avatar
 
Join Date: Jun 2005
Posts: 6,453
Rep Power: 10 DaWei is on a distinguished road
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
DaWei is offline   Reply With Quote
Old Nov 29th, 2005, 8:22 AM   #35
Magius Avvail
Newbie
 
Magius Avvail's Avatar
 
Join Date: Nov 2005
Posts: 23
Rep Power: 0 Magius Avvail is an unknown quantity at this point
Quote:
Originally Posted by DaWei
Ahhh, bit by schlock, after all. <string.h> and <string> aren't equivalents.
Ah... Right, right... So..., which header should I use in order to access the 'string' symbol?
__________________
Magius Avvail
Genocidal Studios™

Administrator
Pasadena, Texas 77502

Compiler: Turbo C++
Compiler: (sometimes) Dev/Borland C++
Programmer Status: Somewhat of a Newb.
Magius Avvail is offline   Reply With Quote
Old Nov 29th, 2005, 8:37 AM   #36
DaWei
Resident Grouch
 
DaWei's Avatar
 
Join Date: Jun 2005
Posts: 6,453
Rep Power: 10 DaWei is on a distinguished road
Quote:
The <STRING.H> is recognized, but it says 'string' is undefined symbol.
By your own statement, it's a good guess it isn't that one. Let me be upfront here. There's a lot of help to be had. Insisting upon your right to be wrong is perfectly legal, but is probably not conducive to efficiently achieving your goal of finding straightforward solutions. I tend to rub a lot of people the wrong way. I don't lose sleep over it. I also don't tend to contribute (my time) gainfully in threads where the OP is refusing to consider the responses. I tried here, I failed. Ce la vie, or however one says it in non-redneck.
__________________
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
DaWei is offline   Reply With Quote
Old Nov 29th, 2005, 8:47 AM   #37
Magius Avvail
Newbie
 
Magius Avvail's Avatar
 
Join Date: Nov 2005
Posts: 23
Rep Power: 0 Magius Avvail is an unknown quantity at this point
Quote:
Originally Posted by DaWei
By your own statement, it's a good guess it isn't that one. Let me be upfront here. There's a lot of help to be had. Insisting upon your right to be wrong is perfectly legal, but is probably not conducive to efficiently achieving your goal of finding straightforward solutions. I tend to rub a lot of people the wrong way. I don't lose sleep over it. I also don't tend to contribute (my time) gainfully in threads where the OP is refusing to consider the responses. I tried here, I failed. Ce la vie, or however one says it in non-redneck.
Oh, man... :p You are rich - I tell ya... You, are, priceless.
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.
Magius Avvail is offline   Reply With Quote
Old Nov 29th, 2005, 10:57 AM   #38
lectricpharaoh
Caffeinated Neural Net
 
lectricpharaoh's Avatar
 
Join Date: Jun 2005
Location: Dry west coast of Canada
Posts: 929
Rep Power: 4 lectricpharaoh will become famous soon enough
Quote:
Originally Posted by Magius Avvail
Oh, man... :p You are rich - I tell ya... You, are, priceless.
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?
There isn't a string function. There is, however, a string class in the standard library of standard C++. Your problem is that the compiler you are using predates the standard. Such compilers sometimes had there own string class, but since there was no standardization of it, each complier vendor did it their own way.

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
lectricpharaoh is offline   Reply With Quote
Old Nov 29th, 2005, 12:05 PM   #39
Magius Avvail
Newbie
 
Magius Avvail's Avatar
 
Join Date: Nov 2005
Posts: 23
Rep Power: 0 Magius Avvail is an unknown quantity at this point
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.
Magius Avvail is offline   Reply With Quote
Old Dec 2nd, 2005, 3:24 PM   #40
Planet_EN
Programmer
 
Join Date: Mar 2005
Posts: 40
Rep Power: 0 Planet_EN is an unknown quantity at this point
Quote:
Originally Posted by Magius Avvail
Oh, man... :p You are rich - I tell ya... You, are, priceless.
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?

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) );
Planet_EN is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 10:46 PM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC