TIP: Click on subject to list as thread! ANSI
echo: c_plusplus
to: RICKEY PARRISH
from: KURT KUZBA
date: 1998-03-25 05:34:00
subject: help with a front-end

RP>   char *runit;
RP>   runit="mpg123";
RP>   runit=runit + "-m -z /stuff/mp3s/example.mp3";
RP>   system(runit);
   If you want to use strings like that in C++, you will have to
   use the string class. VC++ calls theirs CString, and BC++ and
   TC++ call theirs String. Borland does not support string
   concatenation in theirs, as of BC++3.1, though.
   In VC++, you would do this:
CString runit("mpg123");
   or
CString *runit = new CString("mpg123");
runit += "-m -z /stuff/mp3s/example.mp3";
   If you are using Borland, look into using strcat() for adding
   strings together. If you don't have a String class with your
   compiler, then there is a simple one in SNIPPETS, and I can
   post an even simpler one for you that just handles the text
   necessities.
RP>   i THINK open("test.txt"); works, but im not sure because
RP>   I dont know how to write to it or close it or anything :)
   See if this gives you any ideas... :)
//  PUBLIC DOMAIN
#include 
#include 
#include 
int main(void)
{
   ofstream *Write_out = new ofstream("testfile.cfg");
   unsigned char buf[128];
   char *lines[] = {
      "Line one of config file",
      "assorted data these lines",
      "assorted data these lines",
      "assorted data these lines",
      "assorted data these lines",
      "Yes", "No", "Yes", "No", "Yes", "No", "Yes",
      "Line thirteen of config file" };
   for(int line = 0; line < 13; line++)
   {
      int len = sprintf(buf, "%s\n", lines[line]);
      Write_out->write(buf, len);
   }
   delete Write_out;
/*
   ifstream *Read_in = new ifstream("testfile.cfg");
   while(!Read_in->eof())
   {
      Read_in->getline(buf, 128);
      cout << buf << flush;
   }
   delete Read_in;
*/
//  The commented section above would work if my &%!@ Borland
//  compiler would have a working istream.getline() function.
//  It should work in any NORMAL C++ compiler! :)
//  I only get an Undefined Symbol error.
   FILE *Read_in = fopen("testfile.cfg", "r");
   while(fgets(buf, 128, Read_in))
      cout << buf << flush;
   fclose(Read_in);
   return 0;
}
---
> ] Being in the moment is all that there is....................
---
---------------
* Origin: *YOPS ]I[* 8.4 GIG * RA/FD/FE * Milwaukee, WI (1:154/750)

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