|
I am using fgets to get a character array, and then looping through to split it into words by spaces with strtok. For the next step, I am creating a control structure based upon those words. I seem to be able to get the first word but not the next using _strnicmp. It doesn't reuturn 0 when there is a match. I am assuming there is some control character involved that I'm not seeing. Part of the byte is that it has to be C (not C++) and use any non-standard libraries.
So, my question is - how do I do that
and 2, isn't tjhere a better way like a case statement with strings?
I would appreciate any help I can get. Thanks.
Here's the code I have so far:
<br />
<br />
#include <stdio.h><br />
#include <stdlib.h><br />
#include <string.h><br />
#include <mbstring.h><br />
<br />
<br />
char waitkey [10];<br />
char *pch;<br />
<br />
struct map {<br />
char *name;<br />
char *description;<br />
int north;<br />
int south;<br />
int west;<br />
int east;<br />
int up;<br />
int down;<br />
int other;<br />
};
struct map my_map[20] = {<br />
{"Location0", "Dummy Location", 0,0,0,0,0,0,0},<br />
{"Location1", "Admissions", 2,0,0,0,0,0,0},<br />
{"Location2", "Lovely Lounge", 3,1,0,0,0,0,0},<br />
{"Location3", "Main Hallway", 3,1,0,0,0,0,0},<br />
{"Location4", "TV Room", 0,0,0,0,0,0,0},<br />
{"Location5", "Mess Hall", 0,0,0,0,0,0,0},<br />
{"Location6", "Crafts Room", 0,0,0,0,0,0,0},<br />
{"Location7", "Therapy Room", 0,0,0,0,0,0,0},<br />
{"Location8", "Padded Cell", 0,0,0,0,0,0,0},<br />
{"Location9", "Mike's Room", 0,0,0,0,0,0,0},<br />
{"Location10", "Nurse's Station", 0,0,0,0,0,0,0},<br />
{"Location11", "Group Therapy Room", 0,0,0,0,0,0,0},<br />
{"Location12", "Fenced Patio", 0,0,0,0,0,0,0},<br />
{"Location13", "Showers", 0,0,0,0,0,0,0},<br />
{"Location14", "Violent Ward", 0,0,0,0,0,0,0},<br />
{"Location15", "Honest Politician's Ward", 0,0,0,0,0,0,0},<br />
{"Location16", "Depressed College Student's Ward", 0,0,0,0,0,0,0},<br />
{"Location17", "Phone Booth", 0,0,0,0,0,0,0},<br />
{"Location18", "Secret Ritual Room", 0,0,0,0,0,0,0},<br />
{"Location19", "Psychiatrist's Lounge", 0,0,0,0,0,0,0}<br />
};
<br />
int current_room = 1;<br />
<br />
int main(int argc, char* argv[])<br />
{ <br />
printf("*** Josh's fantastic escape from the C Sanitarium for burnt out Coderz ***\n");<br />
printf("\n\n");<br />
printf("LOCATION : %s\n", my_map[current_room].name);<br />
printf("DESCRIPTION : %s\n",my_map[current_room].description);<br />
printf("WHAT'S HERE :\n");<br />
printf("VISIBLE EXITS:");<br />
<br />
if (my_map[current_room].north >= 1)<br />
{<br />
printf("North ");<br />
}<br />
<br />
if (my_map[current_room].south >= 1)<br />
{<br />
printf(" South ");<br />
}<br />
if (my_map[current_room].west >= 1)<br />
{<br />
printf(" West ");<br />
}<br />
if (my_map[current_room].east >= 1)<br />
{<br />
printf(" East ");<br />
}<br />
if (my_map[current_room].up >= 1)<br />
{<br />
printf(" Up ");<br />
}<br />
if (my_map[current_room].down >= 1)<br />
{<br />
printf(" Down ");<br />
}<br />
if (my_map[current_room].other >= 1)<br />
{<br />
printf(" Other ");<br />
}<br />
printf("\n");<br />
printf("\nWhat would you like to do?\n");<br />
char user_command[250];<br />
fgets(user_command, sizeof(user_command), stdin);<br />
fflush(stdin);
printf("\n");<br />
char *words[11];<br />
int wordnumber = 0;<br />
char *pch;<br />
pch = strtok (user_command, " ");<br />
words[wordnumber]=pch;<br />
while ((pch != NULL) && (wordnumber < 10))
{<br />
wordnumber++;<br />
words[wordnumber]=pch;<br />
pch = strtok (NULL, " ,.");<br />
}<br />
int count;<br />
for(count=1;count<=wordnumber;count++)<br />
{<br />
printf("**%s**\n",words[count]);<br />
}<br />
<br />
int result;<br />
char go[] = "go";<br />
result = _strnicmp(words[0], go, 2 );<br />
<br />
if (result==0)<br />
{<br />
printf("You want to go somewhere\n");<br />
char north[] = "north";<br />
char south[] = "south";<br />
char west[] = "West";<br />
char east[] = "east";<br />
char up[] = "up";<br />
char down[] = "down";<br />
char other[] = "other";<br />
<br />
int result;<br />
result = _strnicmp(words[1], north, 5 );<br />
if (result==0)<br />
{<br />
printf("You want to go north\n");<br />
}<br />
result = _strnicmp(words[1], south, 5 );<br />
if (result==0)<br />
{<br />
printf("You want to go south\n");<br />
}<br />
result = _strnicmp(words[1], west, 4 );<br />
if (result==0)<br />
{<br />
printf("You want to go west\n");<br />
}<br />
result = _strnicmp(words[1],east, 4 );<br />
if (result==0)<br />
{<br />
printf("You want to go east\n");<br />
}<br />
result = _strnicmp(words[1], up, 2 );<br />
if (result==0)<br />
{<br />
printf("You want to go up\n");<br />
}<br />
result = _strnicmp(words[1], down, 4 );<br />
if (result==0)<br />
{<br />
printf("You want to go down\n");<br />
}<br />
result = _strnicmp(words[1], other, 5 );<br />
if (result==0)<br />
{<br />
printf("You want to go north\n");<br />
}<br />
}<br />
char blow[]="blow";<br />
result = _strnicmp(words[0], blow, 4 );<br />
if (result==0)<br />
{<br />
printf("blow");<br />
}<br />
<br />
<br />
return 0;<br />
}<br />
|
|
|
|
|
You almost had it right! The problem lies in the organization of your while loop. Try this instead:
while ((pch != NULL) && (wordnumber < 10))
{
++wordnumber;
pch = strtok (NULL, " ,.");
words[wordnumber]=pch;
}
Regards,
|
|
|
|
|
I to tired to study your code but I have the following comments:
First you need to use if else statments, because once a test has been passed there in no need for more testing. Second the comments are C++ comments, which start wit "//" and do not end with anything, although you are ending them with "//"; your comments in C should start with "/*" and end with "*/
".
Now you need to understand how strtok works!
while ((pch != NULL) && (wordnumber < 10))// and word # is acceptable - add later//
{
wordnumber++;
words[wordnumber]=pch;
pch = strtok (NULL, " ,.");
}
What strtock does is set a global pointer to the start of your string on the first call. When it finds a dilimeter it temporaraly replaceses it with a '\0' character and returns a pointer to the start of the token. On the next call it restores the delimiter, and sets the global pointer to the start of the next token (if any). It then looks for the next delimiter and repeats the process.
Note: The first argument is not a constant, what that means is it is changing the string (temporarily). If I typed in a string like so, "north south east west" then your code would produce the following strings:
1) "north south east west"
2) "south east west"
3) "east west"
4) "west"
To understand string functions, just sit down and recreate them!
I was going to write a quick strtok function to show you but it is after 4 AM here and my mind told me where I could put that idea (best not repeated here).
Good Luck!
INTP
|
|
|
|
|
Much appreciated. I changed the comments to C syntax. It's true that I'm not doing proper captue yet (the else statements) but I was hoping to find a better way. Rather than change the while statement I just adapted the bottom so subscripts match. I'm going to see if there is some way I could ste this up with a switch statement. Any suggestions (especially for a better way of processing commands) are much appreciated.
<br />
<br />
<br />
#include <stdio.h><br />
#include <stdlib.h><br />
#include <string.h><br />
#include <mbstring.h><br />
#include <dos.h><br />
<br />
#define CR 0x0d<br />
#define ESC 0x1b<br />
#define TAB 0x09<br />
#define LF 0x0a<br />
#define BACKSPACE 0x08<br />
#define NULL 0<br />
#define TRUE 1<br />
#define FALSE 0<br />
#define LENGTH 80<br />
#define COLS 80<br />
#define VIDEO 0x10<br />
#define ROWS 25<br />
#define DELAY 250<br />
#define MROW 12<br />
<br />
void refresh(void);<br />
void process_command(void);<br />
void main_thing(void);<br />
void cls(void);<br />
<br />
<br />
char user_command[250];<br />
char waitkey [10];<br />
char *pch;<br />
<br />
struct map {<br />
char *name;<br />
char *description;<br />
int north;<br />
int south;<br />
int west;<br />
int east;<br />
int up;<br />
int down;<br />
int other;<br />
}; <br />
struct map my_map[22] = {<br />
{"Location0", "Dummy Location", 0,0,0,0,0,0,0},<br />
{"Location1", "Admissions", 2,0,10,17,0,0,0},<br />
{"Location2", "Lovely Lounge", 3,1,5,4,0,0,0},<br />
{"Location3", "Main Hallway", 20,2,6,13,0,0,0},<br />
{"Location4", "TV Room", 0,0,2,19,0,0,0},<br />
{"Location5", "Mess Hall", 6,0,12,2,0,0,0},<br />
{"Location6", "Crafts Room", 0,5,11,3,0,0,0},<br />
{"Location7", "Therapy Room", 0,0,0,20,0,0,0},<br />
{"Location8", "Padded Cell", 0,0,20,0,0,0,0},<br />
{"Location9", "Mike's Room", 0,0,16,0,0,0,0},<br />
{"Location10", "Nurse's Station", 0,0,0,1,0,0,0},<br />
{"Location11", "Group Therapy Room", 0,0,0,6,0,0,0},<br />
{"Location12", "Fenced Patio", 0,0,0,5,0,0,0},<br />
{"Location13", "Showers", 0,0,3,0,0,0,0},<br />
{"Location14", "Violent Ward", 0,0,0,21,18,0,0},<br />
{"Location15", "Honest Politician's Ward", 0,21,0,0,0,0,0},<br />
{"Location16", "Depressed College Student's Ward", 0,0,21,9,0,0,0},<br />
{"Location17", "Phone Booth", 0,0,1,0,0,0,0},<br />
{"Location18", "Secret Ritual Room", 0,0,0,0,0,14,0},<br />
{"Location19", "Psychiatrist's Lounge", 0,0,4,0,0,0,0},<br />
{"Location20", "Hallway part 2", 21,3,7,8,0,0,0},<br />
{"Location21", "Hallway part 3", 15,20,14,16,0,0,0}<br />
}; <br />
<br />
<br />
int current_room = 1;<br />
<br />
int main(int argc, char* argv[])<br />
{ <br />
<br />
refresh();<br />
process_command();<br />
<br />
<br />
return 0;<br />
<br />
}<br />
<br />
void refresh(void)<br />
{<br />
<br />
cls();<br />
printf("*** Josh's fantastic escape from the C Sanitarium for burnt out Coderz ***\n");<br />
printf("\n\n");<br />
printf("LOCATION : %s\n", my_map[current_room].name);<br />
printf("DESCRIPTION : %s\n",my_map[current_room].description);<br />
printf("WHAT'S HERE :\n");<br />
printf("VISIBLE EXITS:");<br />
<br />
<br />
if (my_map[current_room].north >= 1)<br />
{<br />
printf("North ");<br />
}<br />
<br />
if (my_map[current_room].south >= 1)<br />
{<br />
printf(" South ");<br />
}<br />
if (my_map[current_room].west >= 1)<br />
{<br />
printf(" West ");<br />
}<br />
if (my_map[current_room].east >= 1)<br />
{<br />
printf(" East ");<br />
}<br />
if (my_map[current_room].up >= 1)<br />
{<br />
printf(" Up ");<br />
}<br />
if (my_map[current_room].down >= 1)<br />
{<br />
printf(" Down ");<br />
}<br />
if (my_map[current_room].other >= 1)<br />
{<br />
printf(" Other ");<br />
}<br />
<br />
printf("\n");<br />
printf("\nWhat would you like to do?\n");<br />
<br />
fgets(user_command, sizeof(user_command), stdin);<br />
fflush(stdin);<br />
printf("\n");<br />
}<br />
void process_command(void)<br />
{<br />
<br />
<br />
char *words[11];<br />
int wordnumber = 0;<br />
char *pch;<br />
pch = strtok (user_command, " ");<br />
<br />
words[wordnumber]=pch;<br />
<br />
while ((pch != NULL) && (wordnumber < 10))
{<br />
wordnumber++;<br />
words[wordnumber]=pch;<br />
pch = strtok (NULL, " ,.");<br />
}<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
int result;<br />
char go[] = "go";<br />
result = _strnicmp(words[1], go, 2 );<br />
<br />
if (result==0)<br />
{<br />
<br />
char north[] = "north";<br />
char south[] = "south";<br />
char west[] = "West";<br />
char east[] = "east";<br />
char up[] = "up";<br />
char down[] = "down";<br />
char other[] = "other";<br />
<br />
int result;<br />
result = _strnicmp(words[2], north, 5 );<br />
<br />
if (result==0)<br />
{<br />
<br />
if (my_map[current_room].north >= 1)<br />
{<br />
current_room = my_map[current_room].north;<br />
<br />
main_thing();<br />
}<br />
else<br />
{printf("Can't go there!\n");<br />
}<br />
}<br />
result = _strnicmp(words[2], south, 5 );<br />
if (result==0)<br />
{<br />
<br />
if (my_map[current_room].south>= 1)<br />
{<br />
current_room = my_map[current_room].south;<br />
<br />
main_thing();<br />
}<br />
else<br />
{printf("Can't go there!\n");<br />
}<br />
}<br />
result = _strnicmp(words[2], west, 4 );<br />
if (result==0)<br />
{<br />
<br />
if (my_map[current_room].west >= 1)<br />
{<br />
current_room = my_map[current_room].west;<br />
<br />
main_thing();<br />
}<br />
else<br />
{printf("Can't go there!\n");<br />
}<br />
}<br />
result = _strnicmp(words[2],east, 4 );<br />
if (result==0)<br />
{<br />
<br />
if (my_map[current_room].east >= 1)<br />
{<br />
current_room = my_map[current_room].east;<br />
<br />
main_thing();<br />
}<br />
else<br />
{printf("Can't go there!\n");<br />
}<br />
}<br />
result = _strnicmp(words[2], up, 2 );<br />
if (result==0)<br />
{<br />
<br />
if (my_map[current_room].up >= 1)<br />
{<br />
current_room = my_map[current_room].up;<br />
<br />
main_thing();<br />
}<br />
else<br />
{printf("Can't go there!\n");<br />
}<br />
}<br />
result = _strnicmp(words[2], down, 4 );<br />
if (result==0)<br />
{<br />
<br />
if (my_map[current_room].down >= 1)<br />
{<br />
current_room = my_map[current_room].down;<br />
<br />
main_thing();<br />
}<br />
else<br />
{printf("Can't go there!\n");<br />
}<br />
}<br />
result = _strnicmp(words[2], other, 5 );<br />
if (result==0)<br />
{<br />
<br />
if (my_map[current_room].other>= 1)<br />
{<br />
current_room = my_map[current_room].north;<br />
<br />
main_thing();<br />
}<br />
else<br />
{printf("Can't go there!\n");<br />
}<br />
}<br />
}<br />
char blow[]="blow";<br />
result = _strnicmp(words[1], blow, 4 );<br />
if (result==0)<br />
{<br />
printf("you typed blow");<br />
}<br />
}<br />
void main_thing(void)<br />
{<br />
refresh();<br />
process_command();<br />
}<br />
void cls( void )<br />
{<br />
system("cls");<br />
}<br />
|
|
|
|
|
Hello.
I'm writting application which Open an Access database via OLE DB.
And I want to receave all column metadata With 'IColumnsInfo2::GetRestrictedColumnInfo(...)' , but I cannot(or don't know how) implement IColumnsInfo2 with 'IColumnsRowset'.
i.e.
--------------------------------
IColumnsRowset** ppOLEColumnsInfo;
IColumnsInfo2** ppOLEColumnsInfo2;
.............
HRESULT hr = ppOLEColumnsInfo->QueryInterface(IID_IColumnsInfo2,(void**)ppOLEColumnsInfo2)
//and hr == E_NOINTERFACE
--------------------------------
............
If i try to add 'DBPROP_IColumnsInfo2' property while open 'IColumnRrcorset' with 'IOpenRowset::OpenRowset', result is 'DB_S_ERRORSOCCURRED'.
i.e.
--------------------------------
IOpenRowset** ppOLEOpenRowset;
IColumnsRowset** ppOLEColumnsInfo;
..........
DBPROPSET dbPropSet[1];
ULONG cDbPropCount = sizeof(dbPropSet)/sizeof DBPROPSET;
const ULONG cProperties = 1;
DBPROP rgProperties[cProperties];
pPropSet->rgProperties = rgProperties;
pPropSet->cProperties = cProperties;
pPropSet->guidPropertySet = DBPROPSET_ROWSET;
AddProperty(&rgProperties[1] ,DBPROP_IColumnsInfo2,VT_BOOL,VARIANT_TRUE,DBPROPOPTIONS_OPTIONAL);//doesn't work with DBPROPOPTIONS_REQUIRED, too
............
hr = pOLEOpenRowset->OpenRowset(NULL,&dbID,NULL,IID_IColumnsRowset,
1 ,&dbPropSet,(IUnknown **)&pOLEColumnsRowset );
//and hr == DB_S_ERRORSOCCURRED
//and dbPropSet.rgProperties.dwStatus == DBPROPSTATUS_NOTSUPPORTED
--------------------------------
So, how can i implement Rowset which can implement IDBColumnInfo2 ?
thanks at advice:
KalliMan
a
|
|
|
|
|
Hi all,
This might be a simple question, and you might say that both ways have their own pros and cons (and the pros and cons are so minor, that they are negligible, therefore they are virtually equally efficient). But sometimes I wonder if every single bit of memory and every cpu cycle count, which one is better?
Thanks for any input.
<br />
for(int i=0; i<myArray.GetSize(); i++)<br />
{<br />
if(myArray.GetAt(i).GetValue()==1) { Function1(); }<br />
else if(myArray.GetAt(i).GetValue()==2) { Function2(); } }<br />
else { Function3(); }<br />
}<br />
<br />
for(int i=0; i<myArray.GetSize(); i++)<br />
{<br />
int nValue = myArray.GetAt(i).GetValue();<br />
if(nValue==1) { Function1(); }<br />
else if(nValue==2) { Function2(); }<br />
else { Function3(); }<br />
}<br />
|
|
|
|
|
The answer is, it depends .
If the value returned by <nobr>myArray.GetAt(i).GetValue() is 1, then the two methods will probably have equivalent performance. The fact that you've got a named temporary variable in method 2 doesn't affect the performance, since the compiler generates a temporary variable to hold the return value in method 1.
If the value returned by <nobr>myArray.GetAt(i).GetValue() is >= 2, method 2 will probably execute faster. In method 1, the compiler will generate two calls to <nobr>myArray.GetAt(i).GetValue() . Method 2 only uses a single call. The fact that the function call probably returns the same value is irrelevant, since the compiler can not make that assumption, and therefore must generate and execute code for two calls.
If <nobr>myArray.GetAt(i).GetValue() does not have side effects, then it's safe to assign its value to a temporary and use that, as in method 2.
If <nobr>myArray.GetAt(i).GetValue() does have side effects (successive calls with the same arguments do not return the same results), then you must use method 1.
Software Zen: delete this;
|
|
|
|
|
...but i would like to add
for(int i=0; i<myArray.GetSize(); i++)
myArray.GetSize() is called in every loop, so there is another method call in every loop. you can avoid that by using a temp variable there if the count/loop is large.
I'll write a suicide note on a hundred dollar bill - Dire Straits
|
|
|
|
|
Joe Smith IX wrote:
for(int i=0; i<myArray.GetSize(); i++)
{
int nValue = myArray.GetAt(i).GetValue();
if(nValue==1) { Function1(); }
else if(nValue==2) { Function2(); }
else { Function3(); }
}
How about,
int size = myArray.GetSize ();
for ( int i = 0; i < size; ++i )
{
switch ( myArray.GetAt ( i ).GetValue ())
{
case 1 :
Function1 () ;
break ;
case 2 :
Function2 () ;
break ;
default :
Function3 () ;
break ;
}
}
But if efficiency is relevant the whole structure needs examination.
Paul
|
|
|
|
|
Method (1) is dangerous - it requires that GetValue() has no side-effects. This makes for code that's hard to maintain.
/ravi
My new year's resolution: 2048 x 1536
Home | Articles | Freeware | Music
ravib@ravib.com
|
|
|
|
|
First, the line else if(myArray.GetAt(i).GetValue()==2) { Function2(); } } has an extra brace at the end.
In actual performance the two are identical since they compile to the same thing (at least in VC++ 7.1, but likely also in VC++ 6.0.)
Incidentally, using a switch statement is slightly slower. If there were additional cases, that could change.
[EDIT: At Tim correctly points out, my answer is correct only to the narrow stipulation given. Since GetValue() could involve more than the return of a simple value, it is best to get the value first then test it. The exception would be IF side effects are documented and each test depends on those side effects, though that would be a very odd solution indeed.]
Anyone who thinks he has a better idea of what's good for people than people do is a swine.
- P.J. O'Rourke
|
|
|
|
|
What if the definition of GetValue is in another CPP module? Depending on the link time optimization, that code might not be hoisted into the main routine. Thus the multiple GetValue version would not result in the same code.
Tim Smith
I'm going to patent thought. I have yet to see any prior art.
|
|
|
|
|
That wasn't part of his stipulated conditions.
Anyone who thinks he has a better idea of what's good for people than people do is a swine.
- P.J. O'Rourke
|
|
|
|
|
Nor was the implementation of the routine being inside the same cpp or made inline.
The only reason I bring this up is because you don't tell the full story. What you said is totally true but only under certain conditions.
Tim Smith
I'm going to patent thought. I have yet to see any prior art.
|
|
|
|
|
In general, you should use the second version.
When you have full knowledge of how GetValue is implemented, you can decide which is better. However, that makes caller dependent on the implementation of GetValue. If you ever need to change the implementation, any performance decisions might come back to haunt you. You really shouldn't be depending on GetValue being implemented as it is. Thus that makes the second version the better option.
You should always try to keep relationships between two classes limited to interface only and never the actual implementation. You can't always do this, but when you can, it is best that you do.
Tim Smith
I'm going to patent thought. I have yet to see any prior art.
|
|
|
|
|
Is it free to use the MFC source code however you want, or is that off limits. I don't want to use MFC, but I would like to use bits and pieces of it, like CRect etc. Is this legal, or is it violating any copyrights?
|
|
|
|
|
It's completely legal on the condition that you don't use it to write, and I presume sell, a class library or otherwise represent the code as your own.
Microsoft also requests that you don't compile the new results with the same name as the current MFC libraries.
Anyone who thinks he has a better idea of what's good for people than people do is a swine.
- P.J. O'Rourke
|
|
|
|
|
Hi All,
I am trying to send data from my client to my server through an RPC call in Unix C. I am getting following error:
ServerNameHere: RPC: Unable to send; errno = Bad file number; Illegal file descriptor
I am unaware of nitty gritties of RPC, can anyone help?
I need urgent help. Thanks in advance for any help provided.
Just to elloborate on problem, this error normally comes when I try sending some data 2nd time. I am sending different data each time(taken by user input) in a loop.
Regards,
Ahsan
|
|
|
|
|
Knock Knock...
Anybody home? Someone please answer.
|
|
|
|
|
This is a Visual C++ forum on a site with an almost exclusive Microsoft bias. You're not likely to get help with a UNIX RPC problem here, I'm afraid.
Software Zen: delete this;
|
|
|
|
|
I am a newb to programming, so I use the MFC wizard in VC++ 2003. I would like to have access to the WindowProc function (the function that recieves all the messages), but it is locked. Does anyone know how I could edit the WindowProc function? Anyone that could help, that would be great.
|
|
|
|
|
I need stop the program,
<br />
<br />
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) {<br />
if (stricmp(lpCmdLine, "-noautorun") == 0) {<br />
autorun(); <br />
i cant juse break; <br />
<br />
}else if (lpCmdLine == NULL || _tcslen(lpCmdLine) == 0) {<br />
<br />
MessageBox(NULL, _T("No switch specified"), g_pszCaption, MB_OK | MB_ICONEXCLAMATION);<br />
return 0;<br />
}<br />
<br />
void autorun(){<br />
if void autorun() ends, <br />
the program needs to stop running <br />
<br />
i cant juse return 0;<br />
<br />
return 0;<br />
}<br />
error C2562: 'autorun' : 'void' function returning a value<br />
<br />
thanx for helping me
Greets Jeroen
|
|
|
|
|
Obviously voids can't return a value but I think you could use ExitProcess API or maybe TerminateProcess API. Try this link
-Ryan M.
|
|
|
|
|
Thanx ryan M.
<br />
void autorun () {<br />
<br />
ExitProcess(0); <br />
}}<br />
Jeroen .b
|
|
|
|
|
don't exit() function work too ?
TOXCCT >>> GEII power
|
|
|
|
|