|
camuoi288 wrote: sscanf(cx[i],"&c",&kytux);
Your format constant is incorrect (should be "%c" ), and you are trying to store the response into an uninitialised (and wrong type of) variable. If cx[i] already contains a single character then why are you using sscanf() ?
Also please use <pre></pre> tags around your code (and indentation) to make it readable, like this:
for (i=1; i > count_line; i++)
{
int c;
char *kytux,*kytuy;
c=tamthoi.Find(" ",21*(i-1)+9);
cx[i]=tamthoi.Mid(c+1,9);
cy[i]=tamthoi.Mid(c+6,9);
sscanf(cx[i],"&c",&kytux);
sscanf(cx[i],"&c",&kytuy);
x[i]=atof(kytux);
y[i]=atof(kytuy);
|
|
|
|
|
camuoi288 wrote: sscanf(cx[i],"&c",&kytux); sscanf(cx[i],"&c",&kytuy);
Seems strange to attempt to put cx[i] into both kytux and kytuy .
Why not try:
x[i] = atof(cx[i]);
y[i] = atof(cy[i]);
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Some people are making such thorough preparation for rainy days that they aren't enjoying today's sunshine." - William Feather
|
|
|
|
|
Hi,
Is it possible to know that the choosen printer is a PDF printer? And this programmaticaly?
Thanks,
Claude
|
|
|
|
|
Hi All,
I am tring to figure out is it possible to get the proxy type using C/C++ code.
Lets say i have an IP and Port of a proxy server.
I use it in my code and now my code works using a proxy, so my IP needs to be hide to the world...
I can do some, easy, test to see if the proxy is working or not.
But the thing i realy want to know is what is the proxy type, SOCKS4/5, anonymous/ High anonymous/ Elite one... and so on.
Do you know if there is a way to get this information, re by header info, special value etc.
Thanks a lot for your help,
Ram.
|
|
|
|
|
Hi, I need some help combining these two blocks of if statements. Thanks.
if(segments_comp[head_comp]->panel->Left <= Food->Left)
{
if(segments_comp[head_comp]->panel->Top >= Food->Top){direction_comp =2;}
else{direction_comp=-1;}
}
else if(segments_comp[head_comp]->panel->Left >= Food->Left)
{
if(segments_comp[head_comp]->panel->Top >= Food->Top){direction_comp =2;}
else{direction_comp=1;}
}
if(segments_comp[head_comp]->panel->Top <= Food->Top)
{
if(segments_comp[head_comp]->panel->Left <= Food->Left){direction_comp =-1;}
else{direction_comp=-2;}
}
else if(segments_comp[head_comp]->panel->Top >= Food->Top)
{
if(segments_comp[head_comp]->panel->Left >= Food->Left){direction_comp =1;}
else{direction_comp=2;}
}
|
|
|
|
|
that code is pretty bad, you essentially overwrite direction_comp in the second set of if/else statements, therefore it doesn't matter what the first one does, so combining them is as easy as just keeping the second block
if(segments_comp[head_comp]->panel->Top <= Food->Top)
{
if(segments_comp[head_comp]->panel->Left <= Food->Left)
direction_comp =-1;
else
direction_comp=-2;
}
else
{
if(segments_comp[head_comp]->panel->Left >= Food->Left)
direction_comp =1;
else
direction_comp=2;
}
|
|
|
|
|
Thanks. That code works better.
|
|
|
|
|
Hi all,
i m using this
char buffer[250];
CString str=_T("Test");
strcpy_s(buffer, str);
and this error 'strcpy_s' : none of the 2 overloads could convert all the argument types
comes please help me to resolve this.
|
|
|
|
|
This is happening because you are compiling for Unicode (UNICODE and/or _UNICODE is defined).
If you check on this MSDN page: http://msdn.microsoft.com/en-us/library/td1esda9%28v=vs.80%29.aspx[^] you will see that there is no overload that takes (char *, wchar_t *) (which is what you are passing; the CString in Unicode builds is wchar_t). So you have to convert your char string to wchar_t, or convert your CString to char. Or, don't build for Unicode.
|
|
|
|
|
I compulsory need to build in Unicode mode,
please give any example to solve it with Unicode.
|
|
|
|
|
|
Use the unicode version of the function - wcscpy_s .
Or you could use _tcscpy_s which will work for both unicode and non-unicode builds.
You would also need to define buffer with wchar_t or TCHAR instead of char .
|
|
|
|
|
now its done. but now one more problem generate.
fun1(char * buf);
fun1(char * buf)
{
HRESULT result = _channel->WritePacket((unsigned char*)buf, strlen(buf));
return ( !FAILED(result));
}
wchar_t * wbuf;
_tcscpy_s(wbuf,str.GetLength(),str);
fun1(wBuf);
|
|
|
|
|
You said you want a unicode build.
And char does not support unicode.
Remember that char and wchar_t are different data types and you CANNOT typecast between them.
|
|
|
|
|
Le@rner wrote: fun1(wBuf);
Seems self explanatory. wBuf is a wchar_t but fun1() is expecting a char .
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Some people are making such thorough preparation for rainy days that they aren't enjoying today's sunshine." - William Feather
|
|
|
|
|
there don't use str, use str.GetBuffer(0); or other function to change CString to const char *;
|
|
|
|
|
linc_lee wrote: ...use str.GetBuffer(0);
Completely unnecessary, since CString has a LPCTSTR operator.
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Some people are making such thorough preparation for rainy days that they aren't enjoying today's sunshine." - William Feather
|
|
|
|
|
#include <stdlib.h>
#include <stdio.h>
void main( void )
{
int i;
char *pmbnull = NULL;
char *pmbhello = (char *)malloc( MB_CUR_MAX );
wchar_t *pwchello = L"Hi";
wchar_t *pwc = (wchar_t *)malloc( sizeof( wchar_t ));
printf( "Convert to multibyte string:\n" );
i = wcstombs( pmbhello, pwchello, MB_CUR_MAX ); // Look here !
printf( "\tCharacters converted: %u\n", i );
printf( "\tHex value of first" );
printf( " multibyte character: %#.4x\n\n", pmbhello );
printf( "Convert back to wide-character string:\n" );
i = mbstowcs( pwc, pmbhello, MB_CUR_MAX ); // And here !
printf( "\tCharacters converted: %u\n", i );
printf( "\tHex value of first" );
printf( " wide character: %#.4x\n\n", pwc );
}
Best wish!
|
|
|
|
|
Hi All,
Where can i get the visual studio 4.1 software for downloading?
|
|
|
|
|
There is no software called Visual Studio 4.1 .
You can however get to download Visual C++ 4.2 and Visual Basic 4.0 separately.
For this you will need to buy an MSDN Subscription.
I even see older vesions like Visual C++ 1.52 and Visual Basic 2.0 in the subscription that I have.
|
|
|
|
|
Hi, I am coding an algorithm that searches for a box on the screen. So far I got the snake to find the food which works great except that for example. If the snake is moving right it will sometimes move left and move ontop of it's self. I've spent awhile trying to figure it out on my own with no success. I think it has to do with the two blocks of if statements but I'm not sure. Maybe they need to be combined somehow? This is the last thing I need to figure out and my program is finished. Thanks in advance.
I tried.
if(direction_comp!=1){direction_comp=-1;} else {direction_comp=2;}
direction_comp of 1 = left;
direction_comp of -1 = right;
direction_comp of 2 = up;
direction_comp of -2 = down;
void comp_direction()
{
if(segments_comp[head_comp]->panel->Left <= Food->Left)
{
if(segments_comp[head_comp]->panel->Top >= Food->Top){direction_comp =2;}
else{direction_comp=-1;}
}
else if(segments_comp[head_comp]->panel->Left >= Food->Left)
{
if(segments_comp[head_comp]->panel->Top >= Food->Top){direction_comp =2;}
else{direction_comp=1;}
}
if(segments_comp[head_comp]->panel->Top <= Food->Top)
{
if(segments_comp[head_comp]->panel->Left <= Food->Left){direction_comp =-1;}
else{direction_comp=-2;}
}
else if(segments_comp[head_comp]->panel->Top >= Food->Top)
{
if(segments_comp[head_comp]->panel->Left >= Food->Left){direction_comp =1;}
else{direction_comp=2;}
}
}
modified on Friday, April 15, 2011 7:47 PM
|
|
|
|
|
|
I have a VC project built by VC6 was a MFC app format.
Last year, someone convert it to MFC DLL format and I have to turn it backup, now!
I used VC2008 + sp1 do it, but I got a warning:
Linker Tools Warning LNK4086: entrypoint '_wWinMainCRTStartup' is not __stdcall with 12 bytes of arguments; image may not run.
How to overcome it ?
Best Regard!
|
|
|
|
|
Without seeing the code, it's hard to say what the problem is.
If you can't figure this out, maybe you should consider creating an empty MFC app, and then adding the code from the DLL, piece by piece.
|
|
|
|
|
Hi, Hans
THX
ye, after I pieced code from the DLL, I got a lot of "error LNK2001" and "error LNK2019"
Very peculiar, the Dll project didn't import any libs !?
|
|
|
|