Go to Post Sleep is for the weak - TEntwistle [more]
Home
Go Back   Chief Delphi > Technical > Programming > C/C++
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
 
 
Thread Tools Rate Thread Display Modes
Prev Previous Post   Next Post Next
  #2   Spotlight this post!  
Unread 13-03-2009, 15:35
Jared Russell's Avatar
Jared Russell Jared Russell is offline
Taking a year (mostly) off
FRC #0254 (The Cheesy Poofs), FRC #0341 (Miss Daisy)
Team Role: Engineer
 
Join Date: Nov 2002
Rookie Year: 2001
Location: San Francisco, CA
Posts: 3,078
Jared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond repute
Re: strcat error

I think you think that strcat does something that it doesn't. You can't just cast an int to a char * and expect it to work.

How about:

Code:
 int loop=0;
while (IsAuto())
{
     printf("%d iteration\n", ++loop);
}
That is the most direct way to accomplish what you want. Alternatively, here's how to do it with strcat() properly:

Code:
 int loop=0;
while (IsAuto())
{
     char msg[100]; // We can't just declare this as a "char *" without first allocating memory - 100 characters is more than enough
     strcat( msg, itoa(++loops) );
     strcat( msg, " iteration\n");
     printf("%s", msg);
}
The standard C itoa() function takes an integer and returns a C string of the printable characters.

Last edited by Jared Russell : 13-03-2009 at 15:38.
Reply With Quote
 


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
LebView Error -- Error 1055 occured at Property Node in FRC Create Project.vi->FRC Wi RMS11 Programming 8 08-12-2008 18:20
Error in code light on, trouble finding error Bryan Herbst Programming 16 12-10-2007 21:59
180:Error: syntax error help! seanl Programming 8 04-02-2007 11:31
stupid Array error: Error [1300] stack frame too l Validius Programming 7 27-01-2006 10:53


All times are GMT -5. The time now is 15:06.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi