|
-
Nov 8th, 2000, 01:18 PM
#1
Hi, i need efficient code examples of the following scenarios...
1. How to check the length of a string entered by the user (using the CIN method of the IOSTREAM.H file) and how to truncate a string if it is too long for the target char variable [8].
2. Read and write to a file (sequential access preferably, if that is applicable to C++)
3. Drawing shapes on the screen through code.
Thanks.
-
Nov 8th, 2000, 05:44 PM
#2
Monday Morning Lunatic
I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
-- Linus Torvalds
-
Nov 9th, 2000, 01:33 PM
#3
damn, can someone decypher whatever the heck parksie just said?
I'm using iostream.h and declaring variables as CHAR ... []
What is a namespace?
-
Nov 9th, 2000, 02:41 PM
#4
Monday Morning Lunatic
damn, can someone decypher whatever the heck parksie just said?
It was a bit bad, wasn't it...
I'm using iostream.h and declaring variables as CHAR ... []
That's the point. You're not supposed to use that one. That one's a Microsoft version. The official, real one is iostream. If you use a string, then you can check the length after the text has been entered. Then, use the c_str() member function and strncpy to copy the first eight to your array, to prevent access violations.
It's just a mechanism for making sure that there are no name collisions between different things. All the official parts of the Standard C++ Library are under namespace std.
I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
-- Linus Torvalds
-
Nov 9th, 2000, 02:49 PM
#5
Parksie,
everytime I try the code you have
Code:
#include <string>
using namespace std;
int main()
{
string mystr;
return(0);
}
I get lots of errors, most are in <string>, and it say that
using namespace std;
is wrong syntax
I have tried MSVC++, BC++B, BTC++.... all say that.
-
Nov 9th, 2000, 03:00 PM
#6
Monday Morning Lunatic
Works fine for me (that exact code) in VC++ 5.
I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
-- Linus Torvalds
-
Nov 9th, 2000, 10:14 PM
#7
Frenzied Member
In the build menu, there's an option 'clean', try that, then recompile. If it still doesn't work paste the code into a new project.
Harry.
"From one thing, know ten thousand things."
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|