|
-
Apr 8th, 2001, 04:23 PM
#1
Help!
Could someone please explain how to deal with strings in DJGPP C++?
Also, I would be willing to slave myself to the person that can tell me how to do simple stuff with graphics (lines, rectangles, dots, (bitmaps would be great))
There seems to be no provision at all for graphics in this DJGPP environment (there isn't even a graphics.h file as such!)
I can do classes, macros and god knows what else, but graphics and strings are foreign soil to me (in C++ anyway, I can do it all in VB!).
Any programming deities listening? Kedaman, Parksie...
You can have my girlfriend for a week instead of me if you like!!! heh heh
-
Apr 8th, 2001, 05:19 PM
#2
Monday Morning Lunatic
It was only ever Borland C++ that supplied graphics.h 
To use strings:
Code:
#include <iostream>
#include <string>
int main() {
string x = "Hello world!";
cout << x.substr(3, 5) << endl;
return 0;
}
That's standards-compliant code, so unless DJGPP is totally backwards it should work
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
-
Apr 8th, 2001, 11:37 PM
#3
Addicted Member
-
Apr 9th, 2001, 02:39 PM
#4
Thanks for the input guys.
-
Apr 9th, 2001, 02:39 PM
#5
Hyperactive Member
Originally posted by wossname
Also, I would be willing to slave myself to the person that can tell me how to do simple stuff with graphics (lines, rectangles, dots, (bitmaps would be great)).
Haha... Work, slave!!! I've got a whole OS to build . No, really, here is a link to some graphics stuff for C. It's got tutorials for normal C/C++ and separate ones for DJGPP. Try this link:
http://www.brackeen.com/home/vga
Designer/Programmer of the Comtech Operating System(CTOS)
-
Apr 9th, 2001, 02:49 PM
#6
WOW!
Warmaster, I'm mailing my girlfriend over in an unmarked crate, do with her what you will, and, yes she does!
I will arrive next week to wash your car/bike/helicopter (delete as apropriate), plus daily removal of dog crap from your lawn from that mangy mutt down the street.
Parksie gets all my playboy mags from the last 12 years, (I have chartered a plane especially for this) or at least the ones that bend !!! (tmi?)
Active, you can have my dad's golf clubs, and a jet ski.
-
Apr 9th, 2001, 02:53 PM
#7
Monday Morning Lunatic
Parksie gets all my playboy mags from the last 12 years, (I have chartered a plane especially for this) or at least the ones that bend !!! (tmi?)
Ewww... Not really my material, I'm afraid...too commercialised
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
-
Apr 9th, 2001, 03:03 PM
#8
-
Apr 9th, 2001, 04:42 PM
#9
Hyperactive Member
I recommand that you look at VESA graphics support. Using VESA, you can set the monitor into SVGA modes and colors. It was very useful to me. The link to the VESA site is:
www.vesa.org
Look at the VBE 3.0 specifications. There is an adobe acrobat file that has source code in it.
Originally posted by parksie
It was only ever Borland C++ that supplied graphics.h
I've got an old(ish) kind of compilier called PowerC. It contains a Graphics.h and graphics functions as well.
Designer/Programmer of the Comtech Operating System(CTOS)
-
Apr 12th, 2001, 06:16 PM
#10
Originally posted by parksie
It was only ever Borland C++ that supplied graphics.h 
To use strings:
Code:
#include <iostream>
#include <string>
int main() {
string x = "Hello world!";
cout << x.substr(3, 5) << endl;
return 0;
}
That's standards-compliant code, so unless DJGPP is totally backwards it should work
Don't you need to add using namespace std? Or at least 'using' the namespaces you are... well, using? (std::string, std::cout, std::endl).
-
Apr 12th, 2001, 06:26 PM
#11
Monday Morning Lunatic
You're right...I've answered the questions about the STL so many times now my brain's gone into melt-down over it.
This, of course, is why we need a FAQ.
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
-
Apr 12th, 2001, 09:48 PM
#12
Why don't you write a FAQ, or at least start writing one. Then talk to John about posting an Anouncement only for the C++ forum that will serve as a FAQ?
-
Apr 13th, 2001, 09:36 AM
#13
Okay, I've workied out how to use strings in the most simple sense, but now I need to change a character somewhere in the string...
Code:
string MyString = "Hello World";
string RandomSetOfChars = "abcdef";
/* i want to change the "e" in hello to another character
but this doesn't seem to do it...*/
MyString.substr(1,1) = RandomSetOfChars.subset(random()%6,1);
The character never changes. Is there an equivalent of VB's Mid$() function in the string class?
Maybe I should re-title this thread to: "Why does DJGPP leave out all the documentation?" !
-
Apr 13th, 2001, 10:40 AM
#14
Mid is basicly the same as substr...
Code:
string str = "hello";
string str2 = str.substr(2,2); //str2 now equals ll
the first parameter is the starting point, the second is the depth.
-
Apr 13th, 2001, 11:28 AM
#15
Monday Morning Lunatic
To access a character directly in the string, just use the [] array operators:
Code:
string x = "Hello";
x[3] = "z"; // x = "Helzo"
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
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
|