generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripters
Home Search
 

Re: In C/C++

Previous Thread :: Next Thread 
booing is not online. booing
Joined: 04 May 2009
Total Posts: 6594
07 Oct 2011 06:44 PM
What is the equivalent of string.sub?
Report Abuse
JulienDethurens is not online. JulienDethurens
Joined: 11 Jun 2009
Total Posts: 11046
07 Oct 2011 06:48 PM
I'm not sure, you should check the documentation on cplusplus DOT com. Although there might not be a such function, in which case, writing one yourself would probably be easy.

But, are you using C or C++? If you're using C++, you can use the string library. If you're on C, you need to use tables that contain characters. So it's not the same for C and C++...
Report Abuse
eyeontheprizeREBOOT is not online. eyeontheprizeREBOOT
Joined: 30 Jan 2011
Total Posts: 1555
07 Oct 2011 06:53 PM
with char arrays?
Report Abuse
JulienDethurens is not online. JulienDethurens
Joined: 11 Jun 2009
Total Posts: 11046
07 Oct 2011 06:54 PM
char t = ['h', 'e', 'l', 'l', 'o']

or sumthin liek dat
Report Abuse
TheCapacitor is not online. TheCapacitor
Joined: 19 Jan 2011
Total Posts: 7045
07 Oct 2011 06:56 PM
Well, I guess

("HI").Substring(Start, End);

Ex:

cout >> ("Hello").Substring(2, 1); // "l"
Report Abuse
eyeontheprizeREBOOT is not online. eyeontheprizeREBOOT
Joined: 30 Jan 2011
Total Posts: 1555
07 Oct 2011 06:56 PM
was asking OP
Report Abuse
pokelover980 is not online. pokelover980
Joined: 12 Jun 2009
Total Posts: 4141
07 Oct 2011 07:00 PM
For a std::string, the method would be substr. So:

std::string HelloWorld ("Hello World!");
std::cout << HelloWorld.substr(0, 5);
Report Abuse
eyeontheprizeREBOOT is not online. eyeontheprizeREBOOT
Joined: 30 Jan 2011
Total Posts: 1555
07 Oct 2011 07:01 PM
getting the end of a string with char arrays in C:

#include stdio.h

int main()
{
char* original = "Hello world!";
char* substring = (original+6);
printf(substring);
return 0;
}

> world!
Report Abuse
booing is not online. booing
Joined: 04 May 2009
Total Posts: 6594
07 Oct 2011 07:10 PM
Ty,
i usin C++
Report Abuse
myrkos is not online. myrkos
Joined: 06 Sep 2010
Total Posts: 8072
07 Oct 2011 07:19 PM
"If you're on C, you need to use tables that contain characters."

Wat? You mean character arrays?

Anyways, in C you could do simple pointer mathz to replicate what substr does
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image