OESF | ELSI | pdaXrom | OpenZaurus | Zaurus Themes | Community Links | Ibiblio

IPB

Welcome Guest ( Log In | Register )

> C++ Question
Capn_Fish
post May 1 2007, 05:00 PM
Post #1





Group: Members
Posts: 2,350
Joined: 30-July 06
Member No.: 10,575



I'm making a program for the Z that I need to take a variable and use it as part of a "system (xxxx)" command (or some other command to have the program call another command with args). How do I do that? Sorry if a) this is really obvious or cool.gif this question doesn't make sense. I have very little C++ knowledge, but am trying to learn.

Links to a solution would also be appreciated.

Thanks in advance.
Go to the top of the page
 
+Quote Post
 
Start new topic
Replies
Capn_Fish
post Jun 8 2007, 05:13 PM
Post #2





Group: Members
Posts: 2,350
Joined: 30-July 06
Member No.: 10,575



Is there any way to only use one string-like variable (char[xyz] or string) in my code? Some things complain if I use a char[xyz], but not a string, others work the opposite way, and it would be easier to just use one type instead of converting back and forth.

Thanks.
Go to the top of the page
 
+Quote Post
Meanie
post Jun 8 2007, 06:50 PM
Post #3





Group: Members
Posts: 2,808
Joined: 21-March 05
From: Sydney, Australia
Member No.: 6,686



QUOTE(Capn_Fish @ Jun 9 2007, 11:13 AM)
Is there any way to only use one string-like variable (char[xyz] or string) in my code? Some things complain if I use a char[xyz], but not a string, others work the opposite way, and it would be easier to just use one type instead of converting back and forth.

Thanks.
*



sounds like QString is what you want smile.gif
Go to the top of the page
 
+Quote Post
Capn_Fish
post Jun 8 2007, 06:57 PM
Post #4





Group: Members
Posts: 2,350
Joined: 30-July 06
Member No.: 10,575



QUOTE(Meanie @ Jun 8 2007, 09:50 PM)
QUOTE(Capn_Fish @ Jun 9 2007, 11:13 AM)
Is there any way to only use one string-like variable (char[xyz] or string) in my code? Some things complain if I use a char[xyz], but not a string, others work the opposite way, and it would be easier to just use one type instead of converting back and forth.

Thanks.
*



sounds like QString is what you want smile.gif
*


I'm not using QT. Is that an issue?

Is it possible to just use either strings or character arrays?
Go to the top of the page
 
+Quote Post
Snappy
post Jun 10 2007, 08:51 PM
Post #5





Group: Members
Posts: 793
Joined: 28-November 04
From: NM, US, sometimes Asia
Member No.: 5,633



QUOTE(Capn_Fish @ Jun 9 2007, 10:57 AM)
QUOTE(Meanie @ Jun 8 2007, 09:50 PM)
QUOTE(Capn_Fish @ Jun 9 2007, 11:13 AM)
Is there any way to only use one string-like variable (char[xyz] or string) in my code? Some things complain if I use a char[xyz], but not a string, others work the opposite way, and it would be easier to just use one type instead of converting back and forth.

Thanks.
*



sounds like QString is what you want smile.gif
*


I'm not using QT. Is that an issue?

Is it possible to just use either strings or character arrays?
*



I guess there is no easy way out but to convert them back and forth. Not too familiar with the string definition in QT3, but there might be some cast members that return a pointer from string that can be used as a char pointer in some functions.

Using MFC (Microsoft Foundation Classes) as an example,

CString sMyText;
char szMyText[100];
char * lpszMyText;
sMyText = "Some data here";
lpszMyText = sMyText.GetBuffer(sMyText.GetLength());
// Use lpszMyText

strcpy(szMyText, lpszMyText);

lpszMyText = NULL; // Not required but good practise to null the pointers

// Release buffer pointer
sMyText.ReleaseBuffer();

Hope this make sense. smile.gif
Go to the top of the page
 
+Quote Post

Posts in this topic
Capn_Fish   C++ Question   May 1 2007, 05:00 PM
freizugheit   http://www.cprogramming.com/tips/showTip.p...count...   May 1 2007, 05:56 PM
Meanie   QUOTE(Capn_Fish @ May 2 2007, 11:00 AM)I...   May 1 2007, 06:19 PM
Capn_Fish   OK, I got everything sorted out (for the moment). ...   May 1 2007, 06:31 PM
Capn_Fish   New question: Is jumping in WAY over my head and t...   May 10 2007, 02:17 PM
Meanie   QUOTE(Capn_Fish @ May 11 2007, 08:17 AM)New q...   May 10 2007, 04:15 PM
Capn_Fish   QUOTE(Meanie @ May 10 2007, 07:15 PM)QUOTE(Ca...   May 10 2007, 05:35 PM
pgas   Depending on you background, you might want to try...   May 10 2007, 09:54 PM
Meanie   QUOTE(pgas @ May 11 2007, 03:54 PM)Depending ...   May 10 2007, 10:19 PM
pgas   I wonder if pyqt and python + gtk-server ( http://...   May 11 2007, 12:21 AM
Capn_Fish   Nah, I like C++, and I'll look into QT3. Than...   May 11 2007, 03:51 AM
Capn_Fish   You need -devel libs to compile QT3 on the Z, no? ...   May 15 2007, 09:51 AM
Capn_Fish   Is there any way to only use one string-like varia...   Jun 8 2007, 05:13 PM
Meanie   QUOTE(Capn_Fish @ Jun 9 2007, 11:13 AM)Is the...   Jun 8 2007, 06:50 PM
Capn_Fish   QUOTE(Meanie @ Jun 8 2007, 09:50 PM)QUOTE(Cap...   Jun 8 2007, 06:57 PM
Meanie   QUOTE(Capn_Fish @ Jun 9 2007, 12:57 PM)QUOTE(...   Jun 9 2007, 12:04 AM
Snappy   QUOTE(Capn_Fish @ Jun 9 2007, 10:57 AM)QUOTE(...   Jun 10 2007, 08:51 PM
pelrun   Use std::string wherever you can (and pass const/n...   Jun 10 2007, 05:53 AM
Capn_Fish   Slowly working around my problem, but I have anoth...   Jun 13 2007, 07:28 PM
Capn_Fish   Never mind, I worked around it.   Jun 14 2007, 07:40 AM


Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 



RSS Lo-Fi Version Time is now: 21st December 2014 - 01:35 PM