I want to compare the commandline string with "run" and only run the
app if they are equal. This however does not work even though I can
see pCommandString showing as "run" in the debugger!
LPSTR is #defined as a char*
What am I missing?
thanks
INT WINAPI WinMain(HINSTANCE hInst, HINSTANCE hInst, LPSTR
pCommandString, INT)
{
if (pCommandString == "run")
{
//do stuff
}
return 0;
} 4 3327
scroopy wrote: I want to compare the commandline string with "run" and only run the app if they are equal. This however does not work even though I can see pCommandString showing as "run" in the debugger!
LPSTR is #defined as a char*
What am I missing?
It seem that you think that comparing two pointers is in some magical way
transformed into a string comparison. That's not the case. Try the strcmp()
function instead.
thanks
INT WINAPI WinMain(HINSTANCE hInst, HINSTANCE hInst, LPSTR pCommandString, INT) { if (pCommandString == "run") { //do stuff }
return 0; }
On Fri, 16 Jun 2006 13:47:56 +0200, Rolf Magnus <ra******@t-online.de>
wrote: scroopy wrote:
I want to compare the commandline string with "run" and only run the app if they are equal. This however does not work even though I can see pCommandString showing as "run" in the debugger!
LPSTR is #defined as a char*
What am I missing? It seem that you think that comparing two pointers is in some magical way transformed into a string comparison. That's not the case. Try the strcmp() function instead.
I get the same problem Rolf. For some reason the compare fails... thanks
INT WINAPI WinMain(HINSTANCE hInst, HINSTANCE hInst, LPSTR pCommandString, INT) { if (pCommandString == "run") { //do stuff }
return 0; }
Ignore my last post. I thought strcmp returned 1 if they were equal...
foh
On Fri, 16 Jun 2006 13:42:06 +0100, scroopy <sc*****@doesntexist.com>
wrote: On Fri, 16 Jun 2006 13:47:56 +0200, Rolf Magnus <ra******@t-online.de> wrote:
scroopy wrote:
I want to compare the commandline string with "run" and only run the app if they are equal. This however does not work even though I can see pCommandString showing as "run" in the debugger!
LPSTR is #defined as a char*
What am I missing?
It seem that you think that comparing two pointers is in some magical way transformed into a string comparison. That's not the case. Try the strcmp() function instead.
I get the same problem Rolf. For some reason the compare fails...
thanks
INT WINAPI WinMain(HINSTANCE hInst, HINSTANCE hInst, LPSTR pCommandString, INT) { if (pCommandString == "run") { //do stuff }
return 0; }
scroopy posted: I want to compare the commandline string with "run" and only run the app if they are equal. This however does not work even though I can see pCommandString showing as "run" in the debugger!
LPSTR is #defined as a char*
What am I missing?
thanks
INT WINAPI WinMain(HINSTANCE hInst, HINSTANCE hInst, LPSTR pCommandString, INT) { if (pCommandString == "run") { //do stuff }
return 0; }
Use "strcmp". Or if you want to be a cowboy about it:
if ( *pCommandString == 'r'
&&
pCommandString[1] == 'u'
&&
pCommandString[2] == 'n'
&&
!pCommandString[3] )
{
DoStuff();
}
--
Frederick Gotham This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Elijah Bailey |
last post by:
I have two char arrays of size k.
I want to know which one is bigger (exactly like for instance
I compare two ints/longs/etc.).
What is the fastest way to do this? k <= 10 usually for my...
|
by: Curtis Gilchrist |
last post by:
I am required to read in records from a file and store them in descending
order by an customer number, which is a c-style string of length 5. I am
storing these records in a linked list. My...
|
by: mahurshi |
last post by:
i have a quick question
i am putting a debug flag in my program (i really dont need this
feature, but i figured it might be useful when i get into trouble)
so i want to check if argv is the...
|
by: laxmiuk |
last post by:
I've original version of a table called PMM (Product Material Master).
Thro' a web interface, user can change that table contents. Once
changed, i need to raise an ECN (Engineering CHange Note)...
|
by: William Krick |
last post by:
I'm currently evaluating two implementations of a case insensitive
string comparison function to replace the non-ANSI stricmp(). Both of
the implementations below seem to work fine but I'm...
|
by: ma740988 |
last post by:
There's a need for me to move around at specified offsets within
memory. As as a result - long story short - unsigned char* is the type
of choice.
At issue: Consider the case ( test code ) where...
|
by: Bill Pursell |
last post by:
This question involves code relying on mmap, and thus
is not maximally portable. Undoubtedly, many will
complain that my question is not topical...
I have two pointers, the first of which is...
|
by: william |
last post by:
#include <stdio.h>
int main()
{
char *str=NULL;
char x="today is good!";
printf("%s", str);
str=strtok(x," ");
if (str=="today") //<==here is line that confuses me
printf("they equals!\n");
|
by: Andreas Eibach |
last post by:
Hi,
let's say I have this:
#include <string.h>
#define BLAH "foo"
Later on, I do this:
|
by: TamaThps |
last post by:
I have to write a program that takes the lines of code from a .cpp as a string into an array. Then I need to compute the ratio of total lines of code to the number of comment lines, and ratio of...
|
by: DolphinDB |
last post by:
Tired of spending countless mintues downsampling your data? Look no further!
In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: jfyes |
last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
|
by: PapaRatzi |
last post by:
Hello,
I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
|
by: CloudSolutions |
last post by:
Introduction:
For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
|
by: Defcon1945 |
last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
|
by: Shællîpôpï 09 |
last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
|
by: af34tf |
last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome former...
| |