I don't know how to use std::string?

Whether you're a newbie or an experienced programmer, any questions, help, or just talk of any language will be welcomed here.

Moderator: Coders of Rage

User avatar
unholysavagery
Chaos Rift Cool Newbie
Chaos Rift Cool Newbie
Posts: 73
Joined: Tue Oct 28, 2008 4:27 am

Re: I don't know how to use std::string?

Post by unholysavagery »

avansc wrote:jesus, what happened do atoi, itoa, atof ... etc... see this is why you young people need to learn some C manners.
"warning C4996: 'itoa': The POSIX name for this item is deprecated. Instead, use the ISO C++ conformant name: _itoa. See online help for details."

This function is deprecated, I already tried that and it worked but the correct way to do it is to use a std::string.

avansc your getting to old! :lol:
This is the internet, men are men, women are men and children are the FBI.
User avatar
avansc
Respected Programmer
Respected Programmer
Posts: 1708
Joined: Sun Nov 02, 2008 6:29 pm

Re: I don't know how to use std::string?

Post by avansc »

unholysavagery wrote:
avansc wrote:jesus, what happened do atoi, itoa, atof ... etc... see this is why you young people need to learn some C manners.
"warning C4996: 'itoa': The POSIX name for this item is deprecated. Instead, use the ISO C++ conformant name: _itoa. See online help for details."

This function is deprecated, I already tried that and it worked but the correct way to do it is to use a std::string.

avansc your getting to old! :lol:
lolz, thats just a compiler warning, nothing serious. i doubt that you will trite code that will crash if you use it.
again, you compiled with a C++ compiler, try using something good like gcc.

i might be getting long in the tooth.. ;(
Some person, "I have a black belt in karate"
Dad, "Yea well I have a fan belt in street fighting"
User avatar
Falco Girgis
Elysian Shadows Team
Elysian Shadows Team
Posts: 10294
Joined: Thu May 20, 2004 2:04 pm
Current Project: Elysian Shadows
Favorite Gaming Platforms: Dreamcast, SNES, NES
Programming Language of Choice: C/++
Location: Studio Vorbis, AL
Contact:

Re: I don't know how to use std::string?

Post by Falco Girgis »

avansc wrote:jesus, what happened do atoi, itoa, atof ... etc... see this is why you young people need to learn some C manners.
Yeah, that's what I was thinking when I saw this topic. That's why I didn't respond until after the solution had already been presented, because I don't know how the hell to do some of the good ol' fashioned C things with C++ whore strings.
User avatar
Falco Girgis
Elysian Shadows Team
Elysian Shadows Team
Posts: 10294
Joined: Thu May 20, 2004 2:04 pm
Current Project: Elysian Shadows
Favorite Gaming Platforms: Dreamcast, SNES, NES
Programming Language of Choice: C/++
Location: Studio Vorbis, AL
Contact:

Re: I don't know how to use std::string?

Post by Falco Girgis »

avansc wrote:
unholysavagery wrote:
avansc wrote:jesus, what happened do atoi, itoa, atof ... etc... see this is why you young people need to learn some C manners.
"warning C4996: 'itoa': The POSIX name for this item is deprecated. Instead, use the ISO C++ conformant name: _itoa. See online help for details."

This function is deprecated, I already tried that and it worked but the correct way to do it is to use a std::string.

avansc your getting to old! :lol:
lolz, thats just a compiler warning, nothing serious. i doubt that you will trite code that will crash if you use it.
again, you compiled with a C++ compiler, try using something good like gcc.

i might be getting long in the tooth.. ;(
Yeah, Microsoft has new versions for all of the oldschool C functions that handle exceptions and stuff like that. I still recommend the standard C stuff...
User avatar
trufun202
Game Developer
Game Developer
Posts: 1105
Joined: Sun Sep 21, 2008 12:27 am
Location: Dallas, TX
Contact:

Re: I don't know how to use std::string?

Post by trufun202 »

In college, we weren't allowed to use strings - even if we wrote our own string class... It was char arrays all the way - but, it was good experience.
-Chris

YouTube | Twitter | Rad Raygun

“REAL ARTISTS SHIP” - Steve Jobs
User avatar
unholysavagery
Chaos Rift Cool Newbie
Chaos Rift Cool Newbie
Posts: 73
Joined: Tue Oct 28, 2008 4:27 am

Re: I don't know how to use std::string?

Post by unholysavagery »

trufun202 wrote:In college, we weren't allowed to use strings - even if we wrote our own string class... It was char arrays all the way - but, it was good experience.
How long ago was this?
This is the internet, men are men, women are men and children are the FBI.
User avatar
unholysavagery
Chaos Rift Cool Newbie
Chaos Rift Cool Newbie
Posts: 73
Joined: Tue Oct 28, 2008 4:27 am

Re: I don't know how to use std::string?

Post by unholysavagery »

GyroVorbis wrote:
avansc wrote:
unholysavagery wrote:
avansc wrote:jesus, what happened do atoi, itoa, atof ... etc... see this is why you young people need to learn some C manners.
"warning C4996: 'itoa': The POSIX name for this item is deprecated. Instead, use the ISO C++ conformant name: _itoa. See online help for details."

This function is deprecated, I already tried that and it worked but the correct way to do it is to use a std::string.

avansc your getting to old! :lol:
lolz, thats just a compiler warning, nothing serious. i doubt that you will trite code that will crash if you use it.
again, you compiled with a C++ compiler, try using something good like gcc.

i might be getting long in the tooth.. ;(
Yeah, Microsoft has new versions for all of the oldschool C functions that handle exceptions and stuff like that. I still recommend the standard C stuff...
Well I'm a perfectionist, I spent 2 months rewriting my code so I could remove a 64Kb memory leak. ;)
This is the internet, men are men, women are men and children are the FBI.
User avatar
Arce
Jealous Self-Righteous Prick
Jealous Self-Righteous Prick
Posts: 2153
Joined: Mon Jul 10, 2006 9:29 pm

Re: I don't know how to use std::string?

Post by Arce »

My shit leaked ~2 gb sys ram on Peter's comp at one point...Fucker, burn! :twisted:
<qpHalcy0n> decided to paint the office, now i'm high and my hands hurt
User avatar
MarauderIIC
Respected Programmer
Respected Programmer
Posts: 3406
Joined: Sat Jul 10, 2004 3:05 pm
Location: Maryland, USA

Re: I don't know how to use std::string?

Post by MarauderIIC »

GyroVorbis wrote:
avansc wrote:jesus, what happened do atoi, itoa, atof ... etc... see this is why you young people need to learn some C manners.
Yeah, that's what I was thinking when I saw this topic. That's why I didn't respond until after the solution had already been presented, because I don't know how the hell to do some of the good ol' fashioned C things with C++ whore strings.
In this case, I'd use itoa(). Although iirc it's not standard [but atoi is]. C++ doesn't really have better conversions...

Making your own itoa is this:

Code: Select all

char[] itoa(int i) {
    char buffer[256]; // w/e
    sprintf("%i", buffer);
    return buffer;
}
I realized the moment I fell into the fissure that the book would not be destroyed as I had planned.
User avatar
trufun202
Game Developer
Game Developer
Posts: 1105
Joined: Sun Sep 21, 2008 12:27 am
Location: Dallas, TX
Contact:

Re: I don't know how to use std::string?

Post by trufun202 »

unholysavagery wrote:
trufun202 wrote:In college, we weren't allowed to use strings - even if we wrote our own string class... It was char arrays all the way - but, it was good experience.
How long ago was this?
2000? :(
-Chris

YouTube | Twitter | Rad Raygun

“REAL ARTISTS SHIP” - Steve Jobs
User avatar
Falco Girgis
Elysian Shadows Team
Elysian Shadows Team
Posts: 10294
Joined: Thu May 20, 2004 2:04 pm
Current Project: Elysian Shadows
Favorite Gaming Platforms: Dreamcast, SNES, NES
Programming Language of Choice: C/++
Location: Studio Vorbis, AL
Contact:

Re: I don't know how to use std::string?

Post by Falco Girgis »

Yeah, I have had classes where we weren't allowed to use strings either. Honestly though, I think the character array manipulation was good for me. Too many C++ programmers don't know how to handle C style character arrays...
User avatar
unholysavagery
Chaos Rift Cool Newbie
Chaos Rift Cool Newbie
Posts: 73
Joined: Tue Oct 28, 2008 4:27 am

Re: I don't know how to use std::string?

Post by unholysavagery »

GyroVorbis wrote:Yeah, I have had classes where we weren't allowed to use strings either. Honestly though, I think the character array manipulation was good for me. Too many C++ programmers don't know how to handle C style character arrays...
I know how to do that and then some for instance I used to manage my own arrays and didn't even know about std::vector. You have no idea how complex that made stuff, I learned a lot from it though and I agree that itoa() is much more logical but I've been trying to do absolutely everything by the book. it's worked out well though most of the stuff I just find retarded, I'm hoping to use this as an example of my work in the future.
This is the internet, men are men, women are men and children are the FBI.
User avatar
avansc
Respected Programmer
Respected Programmer
Posts: 1708
Joined: Sun Nov 02, 2008 6:29 pm

Re: I don't know how to use std::string?

Post by avansc »

unholysavagery wrote:
GyroVorbis wrote:Yeah, I have had classes where we weren't allowed to use strings either. Honestly though, I think the character array manipulation was good for me. Too many C++ programmers don't know how to handle C style character arrays...
I know how to do that and then some for instance I used to manage my own arrays and didn't even know about std::vector. You have no idea how complex that made stuff, I learned a lot from it though and I agree that itoa() is much more logical but I've been trying to do absolutely everything by the book. it's worked out well though most of the stuff I just find retarded, I'm hoping to use this as an example of my work in the future.
i would suggest not to use std::vector, especially if you are so adamant on staying efficient.
or anything C++ gives you that makes something people think is complicated into something thats easy.
if you dont know the machanics of something C++ is lettign you use you will have a shit hoard time trying to make something effiecient, becauyse you wont know where your code is being inefficient.
Some person, "I have a black belt in karate"
Dad, "Yea well I have a fan belt in street fighting"
User avatar
Falco Girgis
Elysian Shadows Team
Elysian Shadows Team
Posts: 10294
Joined: Thu May 20, 2004 2:04 pm
Current Project: Elysian Shadows
Favorite Gaming Platforms: Dreamcast, SNES, NES
Programming Language of Choice: C/++
Location: Studio Vorbis, AL
Contact:

Re: I don't know how to use std::string?

Post by Falco Girgis »

The standard template library in C++ is actually pretty damn huge when it comes to executable file size. I'm not saying whether I recommend you go one way or another, but you mentioned efficiency, so I thought that I would bring this up.
Post Reply