| TIP: Click on subject to list as thread! | ANSI |
| echo: | |
|---|---|
| to: | |
| from: | |
| date: | |
| subject: | Re: Pascal strings |
On 21 Oct 93 18:06:00, Steven Pasztor had this to say to Michael Baker:
MB> #include
MB> char * P2Cstr(char * str) {
MB> str[str[0] + 1] = '\0';
MB> return &str[1];
MB> }
MB> char * C2Pstr(char * str) {
MB> /* this assumes str is a pointer to Pstr[1]
MB> where Pstr is an array of char */
MB> char * Pstr = str - 1;
MB> Pstr[0] = strlen(str);
MB> return Pstr;
MB> }
SP> Hmmm... I'll make sure I try them out...
Let me know how it goes. Remember that you will have to be extra
careful with memory allocation as making conversions in either direction
assumes that there is an extra byte allocated either at the start or end
of the string. If you have access to C++ all of this could be put in a
class along with code to check that memory is allocated correctly.
Michael.
--- Blue Wave/Max v2.12
* Origin: Computer Connection - Aust - (+618) 326 2388 (3:800/809.0)SEEN-BY: 50/99 54/54 99 620/243 622/405 623/630 711/401 409 430 807 808 809 SEEN-BY: 711/932 934 712/623 627 713/888 714/906 800/0 1 2 805 809 812 822 SEEN-BY: 800/828 830 843 846 @PATH: 800/809 1 54/54 99 711/808 809 934 |
|
| SOURCE: echomail via fidonet.ozzmosis.com | |
Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.