S
santosh
Bill said:I can't suggest what you should use, because I don't know what you
want to do.
I used %c because it was suggested I use an array of type char. If
char num [10][17] contained different numbers how could I view a
specific element's value of the array using printf? I think that might
answer all my questions if I could know this.
#include <stdio.h>
#include <string.h>
#define NUM_CARDS 10
#define CARD_ID_LENGTH 16
int main(void) {
char card_nos[NUM_CARDS][CARD_ID_LENGTH + 1];
char *example_num = "1234567890123456";
int i;
for (i = 0; i < NUM_CARDS; i++)
strcpy(card_nos, example_num);
/* print numbers with %s specifier */
for (i = 0; i < NUM_CARDS; i++)
printf("card %d: %s\n", i, card_nos);
/* print numbers with a precision modifier to exactly
16 characters. This method works even if the char
sequence is not null terminated
*/
for (i = 0; i < NUM_CARDS; i++)
printf("card %d: %.16s\n",i,card_nos);
return 0;
}