how do you recv() numbers?

Started by
1 comment, last by alexscorpion 18 years, 2 months ago
i thought it would be easy but the following does not work:

//======================================================================
 sprintf(msg, "~file~%s~%lu", szFileTitle, dwFileSize);//my command
 MessageBox(hMainWnd, msg, "send test", MB_OK);
 nRet = send(mainsock, msg, strlen(msg), 0);
//======================================================================
/*
later i revc() it
*/
//======================================================================
if(!strcmp(kom, "file")) //file comming
      {
       //show string!!!
       MessageBox(hMainWnd, msg, "recieved", MB_OK);
       //extract name and length
       i+=1;//skip tilde after the kommand
       int p=0;
       while(msg!='~')
       {
        fName = msg;
        ++p;
        ++i;
       }
       fName = '\0';
       
       char strDW[100]= " +";//MSDN says atol() need it
       p=2;
       while(msg!='\0')
       {
        strDW = msg;
        ++p;
        ++i;
       }
       strDW = '\0';
       
       dwFileSz = atol(strDW);
       //sscanf(strDW, "%lu", &dwFileSz);
       //dwFileSz = ntohl(dwFileSz);
       
       //accept file prompt
       sprintf(strDW, "%s is sending you file: %s %luB big.\r\n \ Do you accept?", remote_name, fName, dwFileSz);
       ret = MessageBox(hMainWnd, strDW, 
                      "File comming", MB_YESNO | MB_ICONQUESTION);
//==========================================================================

the first MB shows exactly what i send but later but the last one does not! it says the file is "0B" /zero/ big. what is wrong with my conversions??? [Edited by - alexscorpion on February 28, 2006 10:26:40 AM]
What man is a man, that makes world no better?
Advertisement
Why don't you step through the code and see where the information is getting lost? Personally I have trouble following your low-level string handling functions and I expect the problem is in there.
actually it is. it was in that: strDW holds "~563" and thats why i get zero from atol...
thank for spending your time reading this
What man is a man, that makes world no better?

This topic is closed to new replies.

Advertisement