TIP: Click on subject to list as thread! ANSI
echo: c_plusplus
to: LEON VARGHESE
from: ANTON S. MAXIMENKO
date: 1997-06-09 14:29:00
subject: String manipulation

    Best wishes,  Leon !
 LV> I have a string:
 LV> "a:\cpp\filename.cdm" and I want to change its file extension
 LV> so it reads  "a:\cpp\filename.trk"
    Use simply circle (such us _while_) and scan your string for a point.
If you'll find point - change last three symbols, if not - add point, three 
symbols of extantion and /0 symb. at the and of string.
char my_string[100];
// There must be functions getting sourse string...
int i=0;
while (my_string[i] != 0 || my_string[i] != '.')
  {
     i++;
  }
if (my_string[i] == '.')
  {
    i++;
    my_string[i] = 't';
    i++;
    my_string[i] = 'r';
    i++;
    my_string[i] = 'k';
    i++;
    my_string[i] = \0; // This is needed if your sourse extension contains 
only // two or one symbs.
}
  if(my_string[i] == \0)
  {
//  Same, but add a point character
   };
    ATTANTION: it will not work if any directory from path have extention.
                                               Hiding in the grave
                                                     Anton S. Maximenko
--- GoldED/386 2.50+
---------------
* Origin: Night is so beautiful (we need her as we need Day) (2:5020/535.29)

SOURCE: echomail via exec-pc

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™.