String 16

In C++ how do I convert an int to a C-style string?

I've been stuck on this for some time now. I want to get a user to enter am int that ranges 1-16 digits long. I then want to send that to a function like this:

char* int_to_cstring(int user_num, char number_string[16])
{
}

In that function I want to store each digit of the int in the char array. How do I go about doing that? I know there is a built in function that converts int to char but I want to make a new one.
Also, will I have to put a '' (null character) in the char[n] that is immediately after the last digit? I'm not too sure how c strings work.

Consider that the remainder left by dividing an int by 10 (decimal) is the binary value of that particular decimal digit. Add the appropriate value to convert to ASCII ('0'), and you have the display digit. Then divide the original value by 10 (decimal) and use the quotient for the next cycle. Stop when the quotient is zero.

Yes, you do need to put a null at the end. I suggest you fill number_string[] with them before even starting the conversion.

I think this is known as a "cascading polynomial" by the way. A similar method is used to convert ASCII to an int.

Hope that helps.

Discover String 16 On eBay Below:

New Natural Viola Bow for StudentBeginnerSchoolReplacementOrchestraBand
New Natural Viola Bow for StudentBeginnerSchoolReplacementOrchestraBand
$22.99
New 16 Acoustic Viola + Case + Bow Black Pink White Blue Green Brown Natural
New 16 Acoustic Viola + Case + Bow Black Pink White Blue Green Brown Natural
$38.56
New 16 Professional Adult Acoustic Viola Natural Black Pink White Blue Green
New 16 Professional Adult Acoustic Viola Natural Black Pink White Blue Green
$39.99
Yinfente 5string Electric Acoustic Viola 16inch Free Case+Bow+Cable+RosinEL1
Yinfente 5string Electric Acoustic Viola 16inch Free Case+Bow+Cable+RosinEL1
$179.10
Yinfente 5String Electric Silent Viola 16inch SolidWood Free Case+Bow+Cable EL2
Yinfente 5String Electric Silent Viola 16inch SolidWood Free Case+Bow+Cable EL2
$139.00
new 16 inch viola Maple Wood Spruce wood Advance level Viola Case Bow
new 16 inch viola Maple Wood Spruce wood Advance level Viola Case Bow
$109.00
New 16 Inch Practice White Acoustic Viola with Case Rosin Bow for Beginner
New 16 Inch Practice White Acoustic Viola with Case Rosin Bow for Beginner
$39.99
Parisier Lupot Copy 16 One Piece Back Viola with Protec Professional Case
Parisier Lupot Copy 16 One Piece Back Viola with Protec Professional Case
$1,000.00
Vintage William Lewis  Son 16 Viola 2520 16 w Bow  Hard Case LP2069751
Vintage William Lewis Son 16 Viola 2520 16 w Bow Hard Case LP2069751
$249.95
Viola Scherl  Roth R403E16 16 4 4 Viola
Viola Scherl Roth R403E16 16 4 4 Viola
$100.00
ANTIQUED STUDENT LEVEL 16 GEMS 1 BIRDS EYE ONE PIECE BACK VIOLA CODE B1253
ANTIQUED STUDENT LEVEL 16 GEMS 1 BIRDS EYE ONE PIECE BACK VIOLA CODE B1253
$558.00
16 Electric viola silent wonderful Solid wood Powerful Sound +gifts EV8
16 Electric viola silent wonderful Solid wood Powerful Sound +gifts EV8
$159.00
16 inch Electric Viola Big Jaclk Maple spruce Sweet Sound Hand Made Free Case
16 inch Electric Viola Big Jaclk Maple spruce Sweet Sound Hand Made Free Case
$152.10
New 16inch Electric Viola 4strings Powerful Sound Nice Sound brown colorEL2
New 16inch Electric Viola 4strings Powerful Sound Nice Sound brown colorEL2
$169.00
Guarneri Style SONG Brand profession Master 16 viola of one piece back 11657
Guarneri Style SONG Brand profession Master 16 viola of one piece back 11657
$629.10
16 Inch Electric Viola big jack Solid Wood Powerful Sound Free Violin Case Bow
16 Inch Electric Viola big jack Solid Wood Powerful Sound Free Violin Case Bow
$169.00
Yinfente 16 inch Viola Dark Red 5 string electric Viola Free Viola Case Bow
Yinfente 16 inch Viola Dark Red 5 string electric Viola Free Viola Case Bow
$269.00
Yinfente 16 inch Viola Black 5 string electric Viola Silent pickup Solid wood
Yinfente 16 inch Viola Black 5 string electric Viola Silent pickup Solid wood
$259.00
Yinfente 16 inch Viola Dark Red Electric viola Free Case Bow Ebony Fittings
Yinfente 16 inch Viola Dark Red Electric viola Free Case Bow Ebony Fittings
$169.00
Yinfente Electric Viola 16inch Solid wood Handmade Free Case Bow Rosin EL24
Yinfente Electric Viola 16inch Solid wood Handmade Free Case Bow Rosin EL24
$269.10
Electric silent Viola 4string 16inch Solid wood nice Sound WhiteEL19
Electric silent Viola 4string 16inch Solid wood nice Sound WhiteEL19
$179.10
Yinfente 16inch 5string Electric silent Viola handmade Free case
Yinfente 16inch 5string Electric silent Viola handmade Free case
$181.09
Yinfente 16inch Electric silent Viola Natural wood Free casebow cableEL3
Yinfente 16inch Electric silent Viola Natural wood Free casebow cableEL3
$153.79
Merano New Set of Viola Strings for StudentBeginnerReplacementSchoolGift
Merano New Set of Viola Strings for StudentBeginnerReplacementSchoolGift
$8.99
Yinfente 16 inch viola electric guitar shape electric viola Ebony Fittings
Yinfente 16 inch viola electric guitar shape electric viola Ebony Fittings
$209.30
1x Viola Bow 16 Inch Straight ebony frog Pretty inlay High Quality ZT 073
1x Viola Bow 16 Inch Straight ebony frog Pretty inlay High Quality ZT 073
$25.00
Merano New 4 Sets of Viola Strings+Free Bridge for StudentBeginnerSchool
Merano New 4 Sets of Viola Strings+Free Bridge for StudentBeginnerSchool
$19.99
new 1pcs 16 Electric viola silent wonderful Solidwood Powerful Sound VL8
new 1pcs 16 Electric viola silent wonderful Solidwood Powerful Sound VL8
$209.00
Merano New Set of Viola Strings+Bridge+Tuner for StudentBeginnerReplacement
Merano New Set of Viola Strings+Bridge+Tuner for StudentBeginnerReplacement
$14.99
FOM Violin Shoulder Rests Comfortable Adjustable 4 4 1 16
FOM Violin Shoulder Rests Comfortable Adjustable 4 4 1 16
$7.99
New Electric 16 viola 4String Spruce top Maple back ebony parts VL1
New Electric 16 viola 4String Spruce top Maple back ebony parts VL1
$169.00
Otto Benjamin MA500 16 Viola with Case  Bow
Otto Benjamin MA500 16 Viola with Case Bow
$499.00


Recently Purchased String 16:


song brand maestro 16 violaflame backprofessional viola 9032, new romanian 16 intermediate level gems 1 viola, new helmke viola 16 antique finish w case bow rosin amp; extra strings, new 16 12 viola lowest pricebest quality11347, new 16 viola lowest pricebest quality11067, bellafina roma select series viola outfit 16 in, beginner 16 viola spruce faceboard maple wood backboard glossy tigrina b7y1, glossy tigrina 16 inch viola spruce faceboard maple wood backboard j0l3, gorgeous tartini violin stradivarious model 16 viola wcasehygrometer, song brand maestro 16 violaflame one piece backprofessional viola 9036, cremona sva100 16 viola outfit, romanian 16 flamed maple handmade maestro vasile gliga viola from violinslover, master performancecopy strad 16 viola warm deep toneoil varnishm3522, new 16 12 viola lowest pricebest quality11333, mathias thoma mt140 16 viola used, blue viola case for up to 1616 12 viola $ pay to save a dog, cremona sva130 premier novice series viola outfit 16 in outfit 190839439338 ob, 16 viola by erwin otto with case and bow, palatino va450 allegro viola outfit 16 w case, cecilio cvn100 44 full size viola 16, 16 otto benjamin viola 2010, beautiful solid wood white color 5 stirngs 16 electric amp; acoustic viola , new student blue adult acoustic viola with case rosin bow 16, new 16 student school green adult acoustic viola with case rosin bow, yinfente electric silent viola 16inch solidwood free case bow rosin el18, best model celluloid tortoise shell electric viola 16 acoustic viola 16 , solid wood white color 4 strings 16 electric acoustic violagood sound wsets, handmade 16 maestro gliga antiqued viola from violinslover, german oil antiquea strad model t20 viola 16 deep warm tone, guarneri style song brand master green 16 violaresonant and bigger sound 9706, guarneri style song brand master 16 violaflames maple backhuge sound 11670, odoca ova200 student viola 16, 16 viola, solid wood black 5 strings 16 inch electric violawonderful sound wcase, strad 16 handmade maestro vasile gliga flamed viola, yinfente 5string electric viola 16inch handmade free case bow cable rosin el20, bellafina educator series viola outfit 16 in ln, karl bauer viola 16 lewis and sons selmer co 1998 with carboni bow, 44 size solid maple viola 16 inch with case bow bridge strings rosin hot w2i9, great 16 viola, yinfente 5string electric viola 16inch professional ebony fitting free case bow, viola 16 stephan ulrich with caseextras, new 16 viola lowest pricebest quality11088, yinfente 5string electric silent viola 16inch natural wood free case bow el8, stradivari 16 handcrafted intermediate level gems 1 viola, yinfente electric viola 16inch viola nice sound free casebowrosincable el3, new 16 viola lowest pricebest quality11053, glaesel 16 viola used great for studets, otto benjamin ma500 16 viola with case amp; bow, viola scherl amp; roth r403e16 16 44 viola, yinfente 5string electric silent viola 16inch free casebowrosincable el2, yinfente electric silent viola 16inch blue natural wood free case bow cablee2, maestro stradivarius 16 viola copy 7881 powerful tone, new 16 viola lowest pricebest quality11046, new 16 viola lowest pricebest quality11039, yinfente 5string electric silent viola 16inch solidwood free casebowcable el2, 15 and 16 basswood 4 string acoustic viola basebowrosin



Comments are closed.