Click here to Skip to main content
15,893,622 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: WM_QUERYENDSESSION Pin
Sauro Viti8-Nov-10 20:55
professionalSauro Viti8-Nov-10 20:55 
QuestionTracking application crashes in 'C' Pin
coder21k8-Nov-10 19:08
coder21k8-Nov-10 19:08 
AnswerRe: Tracking application crashes in 'C' Pin
Cedric Moonen8-Nov-10 20:27
Cedric Moonen8-Nov-10 20:27 
AnswerRe: Tracking application crashes in 'C' Pin
Moak9-Nov-10 2:13
Moak9-Nov-10 2:13 
Questionconverting function float to string for sprintf Pin
rezen858-Nov-10 14:07
rezen858-Nov-10 14:07 
AnswerRe: converting function float to string for sprintf Pin
KingsGambit8-Nov-10 17:08
KingsGambit8-Nov-10 17:08 
AnswerRe: converting function float to string for sprintf Pin
CPallini8-Nov-10 23:19
mveCPallini8-Nov-10 23:19 
GeneralRe: converting function float to string for sprintf Pin
rezen859-Nov-10 14:53
rezen859-Nov-10 14:53 
hi,
thanks for replying.The solution you gave me doesn't work as my editor gave me an error:(In function 'void loop()':
error: expected primary-expression before 'char').Maybe you would like to take a look at the whole code as I've been trying several methods but it still doesn't work.I'm just a beginner in c++ so do bear with me.Thanks

C++
float tmpVALUE=0;
int n=0;


void setup(){
   SensorEvent.setBoardMode(SENS_ON);
 
  XBee.setMode(XBEE_ON);
  delay(50);
  USB.begin();
  USB.println("USB port started...");
  USB.close();
  
  // Powering BT
  BT.ON();
  
  if( BT.flag & BT_ERROR_ON ) USB.println("Error, 'ROK' not received");
  else USB.println("BT module ready...");
  
  // Init
  if(!BT.init()) USB.println("Init OK");
}

void loop()
{
    float tmpVALUE=0;    //necessary to place it here to get temp reading
    char dataToSend[100];
    char converttmpVALUE=0;
    
    
    
    
    
    
  // Creating a connection to a device
  if(!BT.createConnection("0003190D102D","02"))
  {
    USB.println("");
    USB.print("--- CONNECTION -- MTU: ");
    USB.print(BT.connection_mtu[0],BYTE);
    USB.print(BT.connection_mtu[1],BYTE);
    USB.println(BT.connection_mtu[2],BYTE);    
  }
  else USB.println("Connection failed");
  
  
  tmpVALUE = SensorEvent.readValue(SENS_SOCKET5);
  
  if(tmpVALUE>0.5)
  {
    tmpVALUE=((tmpVALUE-0.5)/0.01);
  }
  else
  {
    tmpVALUE=tmpVALUE/0.01;
  }
  
  delay(100);
  XBee.print("Temperature: ");
  XBee.println(tmpVALUE);
  delay(5000);
  
  
  // obtain and sending tmpVALUE
  sprintf(dataToSend,"%s",converttmpVALUE);  
   ftoa(char* buf,float f,int p);
   {
  int i, n;
  unsigned long l
  
  for (n=0; n<p; n++)
    f *= 10;

  l = (long) (f + .5);

  for (n=0; l>0; n++, l/=10)
  {
    if (n==p)
    {
      buf[n]='.';
      n++;
    }
    buf[n]= (l % 10) + '0';
  }

  for(i=0; i<n/2;i++)
  {
    char c;
    c = buf[i];
    buf[i] = buf[n-1-i];
    buf[n-1-i]= c;
  }

  buf[n]='\0';
}
  if(!BT.sendData(dataToSend)) USB.println("Data sent OK");
  else USB.println("Error while sending data");
  
  // Removing the connection previously opened
  if(!BT.removeConnection()) USB.println("Connection removed");
  else USB.println("Error while removing connection");  
  
  // Removing a trusted device
  if(!BT.removeTrustedDevice("0003190D102D")) USB.println("Trusted Device removed");
  else USB.println("Error while removing trusted device");

  delay(5000);
}

QuestionWhat to do when GetOverlappedResult results in ERROR_IO_INCOMPLETE Pin
Code-o-mat8-Nov-10 9:05
Code-o-mat8-Nov-10 9:05 
AnswerRe: What to do when GetOverlappedResult results in ERROR_IO_INCOMPLETE Pin
«_Superman_»8-Nov-10 9:37
professional«_Superman_»8-Nov-10 9:37 
GeneralRe: What to do when GetOverlappedResult results in ERROR_IO_INCOMPLETE Pin
Code-o-mat8-Nov-10 10:04
Code-o-mat8-Nov-10 10:04 
GeneralRe: What to do when GetOverlappedResult results in ERROR_IO_INCOMPLETE Pin
«_Superman_»8-Nov-10 10:12
professional«_Superman_»8-Nov-10 10:12 
GeneralRe: What to do when GetOverlappedResult results in ERROR_IO_INCOMPLETE Pin
Code-o-mat8-Nov-10 21:30
Code-o-mat8-Nov-10 21:30 
Questionchar * - returning address of local variable or temporary Pin
piul8-Nov-10 5:11
piul8-Nov-10 5:11 
AnswerRe: char * - returning address of local variable or temporary Pin
Alain Rist8-Nov-10 5:23
Alain Rist8-Nov-10 5:23 
GeneralRe: char * - returning address of local variable or temporary Pin
piul8-Nov-10 5:29
piul8-Nov-10 5:29 
GeneralRe: char * - returning address of local variable or temporary Pin
Alain Rist8-Nov-10 5:59
Alain Rist8-Nov-10 5:59 
AnswerRe: char * - returning address of local variable or temporary Pin
jschell8-Nov-10 5:39
jschell8-Nov-10 5:39 
AnswerRe: char * - returning address of local variable or temporary Pin
David Crow8-Nov-10 5:40
David Crow8-Nov-10 5:40 
AnswerRe: char * - returning address of local variable or temporary Pin
Sauro Viti8-Nov-10 5:50
professionalSauro Viti8-Nov-10 5:50 
AnswerRe: char * - returning address of local variable or temporary Pin
«_Superman_»8-Nov-10 7:03
professional«_Superman_»8-Nov-10 7:03 
AnswerRe: char * - returning address of local variable or temporary Pin
tom144312-Nov-10 2:26
tom144312-Nov-10 2:26 
Questionedit control not responding in a dialog created within an activex control Pin
lakshman rao8-Nov-10 2:59
lakshman rao8-Nov-10 2:59 
QuestionRe: edit control not responding in a dialog created within an activex control Pin
David Crow8-Nov-10 3:36
David Crow8-Nov-10 3:36 
AnswerRe: edit control not responding in a dialog created within an activex control Pin
lakshman rao8-Nov-10 3:48
lakshman rao8-Nov-10 3:48 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.