سلام
چجوری میشه در زبان c برنامه ای نوشت که رشته ای از اعداد رو بگیرد و معادل عددی انها رو چاپ کند ؟ مثل : "245"----> 245
سوال در مورد یه برنامه
مدیران انجمن: abbas.m.k, athlon64x2, شوراي نظارت

-
- پست: 26
- تاریخ عضویت: شنبه ۱۲ دی ۱۳۸۸, ۱۲:۲۶ ق.ظ
- سپاسهای ارسالی: 1 بار
- سپاسهای دریافتی: 42 بار
Re: سوال در مورد یه برنامه
سادست
string Text = "456";//string containing the number
int Result;//number which will contain the result
stringstream convert(Text); // stringstream used for the conversion initialized with the contents of Text
if ( !(convert >> Result) )//give the value to Result using the characters in the string
Result = 0;//if that fails set Result to 0
//Result now equal to 456
string Text = "456";//string containing the number
int Result;//number which will contain the result
stringstream convert(Text); // stringstream used for the conversion initialized with the contents of Text
if ( !(convert >> Result) )//give the value to Result using the characters in the string
Result = 0;//if that fails set Result to 0
//Result now equal to 456

- پست: 210
- تاریخ عضویت: یکشنبه ۳۱ مرداد ۱۳۸۹, ۱:۴۷ ب.ظ
- سپاسهای ارسالی: 4791 بار
- سپاسهای دریافتی: 1452 بار
- تماس:
Re: سوال در مورد یه برنامه
سلام دوست عزیز
"abc123te6st" --> خروجی : 1236
کد برنامه به زبان ++C :

موفق و پیروز باشید
"abc123te6st" --> خروجی : 1236
کد برنامه به زبان ++C :

موفق و پیروز باشید

