Re: Add items to an array
- From: "Default User" <defaultuserbr@xxxxxxxxx>
- Date: 23 Jun 2008 18:38:34 GMT
Kevin Walzer wrote:
I'm trying to generate an array of serial numbers for use in an
application. I can get individual serial numbers printed to stdout
using a for loop, but I cannot figure out how to append these numbers
to an array.
char appname[] = "MYAPP";
int serials[20000];
In a higher-level language such as Python I'd do something like this:
serialnumber = ("%s-%i-%i-%i\n", appname, five, eleven, one)
serials.append(serialnumber)
The array serials[] is one containing ints. You have created strings
with non-numeric components (like the app name). What exactly would you
expect this append() to do? You certainly haven't created an int of any
kind. You have a string. Why not an array of strings?
Brian
.
- References:
- Add items to an array
- From: Kevin Walzer
- Add items to an array
- Prev by Date: Re: The type of argv in K&R2
- Next by Date: Re: Pedants
- Previous by thread: Re: Add items to an array
- Next by thread: Re: Add items to an array
- Index(es):
Relevant Pages
|
Loading