arrays - assign integers to strings in C -


Is there no way in c to assign a string with an integer

I have strings Has a 2d array and I know that it has already been assigned with indexed but I want to assign to each with a random number such as an ID. I do not know if I am submitting it to the array or when I am directly reading the message.

I have to do something like this

2d array: <

What do I need:

  john - 234 michael - 432 simon - 489  

My Function Code for Entering Name in an Array

  Int Store (Four * Stock) {int r; Fixed four trials [5] [10]; Static I = 0; Int K, J = 0; // it just strcpy another function (test [i], copies of names from stock); Printf ("index% s:% d \ n", test [i], i); Qsort (test, i, 10, cmp); If (I == 4) {for (j = 0; j & lt; 5; j ++) {printf ("% s \ n", test [j]); }} I ++; }  

thanks

let you an integer by

use ltoa () / ita () / _ itoa_s () or sprintf () / snprintf ()

use

Note: Be aware of buffer overrun, like safe editions. Safe way to use all functions SprintF () if your platform lack snprintf () or _itoa_s () (1) To avoid uneven format string (% s, etc.) and (2) to identify what you are formatting, and its maximum limits

example, for 64-bit integer:

Maximum value:

  18,446,744,073,70 9,551,615  

The base has its 10 ASCII length 20 ac Will Sr. Use an order extensively for a character buffer. I want to use a 1024 length buffer for sprintf () conversions.

  18446744073709551615 (unsigned) will be approximately 20 lengths. Four buff [1024]; Int64_t Level; Sprintf (buf, "% d", average); Return strdup (buf); // Then duplicate it, or use the Molok Hep Mame string for your copy  

Comments