From: ultrastar AT online DOT tietokone DOT fi (Niki Ruusunko) To: djgpp AT delorie DOT com Date: Tue, 28 Jul 1998 18:43:46 +0300 Subject: sprintf and 64 bit integers Message-ID: Organization: Tietokone Online MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit Content-ID: Precedence: bulk I have this problem with a function I use to do thousands separators to integers. Here is the code: char * LargeInt(unsigned int bignumber) { int counter = -1, i, i2 = 0, sep = 0; char string1[21]; char string2[27]; sprintf(string1, "%d", bignumber); i = strlen(string1); while(i >= 0) { if (counter < 3) { string2[i2] = string1[i]; counter++; } else { string2[i2] = ','; i2++; string2[i2] = string1[i]; counter = 1; sep++; } i--; i2++; } i = 0; i2 = strlen(string1) + sep; while(i2 >= 0) { tmpInt[i] = string2[i2]; i++; i2--; } return tmpInt; } It isn't very good function but it works (on ints that is). The problem is that I need it to support the "long long" -variables I use. Sprintf doesn't compile with a long long as the argument (it says: "warning: int format, different type arg (arg 3)") so I'm asking if there is an alternate function to make a string out of an int (or, a long long in this case). Of course, if you know how to make the separators some better way, please tell me.