Smite...Strings!!!!

Started by
2 comments, last by Zahlman 17 years, 9 months ago
Ah, Hello. This is actually the first time I've posted here on the forum and I apologize if anything here goes off topic. I just have a little bit to say and I don't want to make 4 separate posts in different forum sections.. First, I'd like to call myself a programmer but alas I am a novice. I have a question about Full sail because I think a few people here have a valued opinion on it since I think some people here have experience. I actually live about 2 hours from Full sail so I had planned to go there ever since I visited there and talked with the people on campus. I was fascinated the first time around. The people there were awesome, the campus was awesome, and so were the teachers whom I got to see at the "tour". What is the ultimate community decision against Full sail because I hear so many good and bad things about it. I don't want to spend 60 thousand my first year just to have it slapped back in my face by a game company and say, "Hah! Full sail! Why don't you go over to the makers of Oberin. Maybe they will hire you!" I researched Full sail online and I know they don't give a published credit and that somewhat worries me but I don't think it's that much of an issue. I also read that 50% of the people their drop out because they just aren't willing to work hard enough. I plan on being the graduation 50% if I go there. I still have two years to research it and decide but I just wanted to have all the time I need to find out as much as possible since this is a major life decision. Anyway, enough about college I also needed help with one other thing before I get to my main problem. I would like to join the GameDev Chat but I just can't. When I go to try to view the page the whole IE just crashes, I've tried to view the page in Firefox and I get the same result. Maybe there is another client or some other way I could join the GameDev chat. Now, my string problem. Up until now I have been using C-style strings in my project but C-style strings aren't exactly working up to this point so I'm changing my code. I'm programming a MUD engine with a scripting language for ease of use so anyone with little knowledge of C++ will be able to use my engine to make a MUD. So far I've got the PARSER working to take all the room names with my language so far and parse them into the map's Map vector properly but now I want to make a function that basically takes a string and breaks it in half taking 3 parameters since it's the only way I know I could do it. The first parameter is the string to break apart, the second is which side to return (left or right), and the third parameter is the separation character. This is all fine and dandy but I'm having a problem with this. It's a string type function and I'm returning a string, but I can't pass the string into the string functions from <string.h> which is a problem because that's how I'm breaking my strings apart. I have read a few articles on strings but they haven't exactly gone into depth. All they have told me is how to declare strings, and declare strings as character arrays and use the <string.h> functions on character arrays. How would I pass my strings into the string functions so I can break them apart and copy them into another string then to be returned? I tried passing the string in with a pointer to [0] but it still didn't work. I am really happy to join the GameDev community and traveling the long journey to become a Game Programmer.
Advertisement
Welcome to GameDev [smile]

If you're using C++ style std::strings, they come with a bunch of operators to do this for you, so you don't need to use the C style string functions.
First, you should be including <string>, not <string.h> to use std::string.

std::string has a function called find() which returns the position of the substring found, or std::string::npos if it's not found. There's also substr(), which extracts a substring from the parent string.

Example:
std::string foo = "Hello World!";size_t nPos = foo.find(' ');// nPos == 5 nowstd::string strHello = foo.substr(0, nPos); // Start from 0, and copy nPos charsstd::string strWorld = foo.substr(nPos+1); // Start from nPos+1, and copy the rest of the string (right side)// strHello now contains "Hello"// strWorld now contains "World"

I'd advise getting a good book on the STL if you've never used it before, or finding some tutorials online (I don't know of any unfortunately).
Oh wow, that so much easier than what I had! Thank you. I'll definately look up some books or tutoriols on the subject.
Quote:Original post by NullProgrammer
I would like to join the GameDev Chat but I just can't. When I go to try to view the page the whole IE just crashes, I've tried to view the page in Firefox and I get the same result. Maybe there is another client or some other way I could join the GameDev chat.


o_O?

The only "GameDev chat" I know about is an IRC channel. Are you trying to use some Java client off a webpage? You are probably better off getting an actual dedicated IRC client.

This topic is closed to new replies.

Advertisement