/* ===================================================================*/ static void realtime2str(char* str) { char s[20]; char ampm[4] = ""; LDD_RTC_TTime timePtr; RTC1_GetTime(NULL, &timePtr); strcpy(str, ""); if (imperialUnits) { // imperial units if (timePtr.Hour > 12) { itoa2(timePtr.Hour - 12, s); strcpy(ampm, " pm"); } else { itoa2(timePtr.Hour, s); strcpy(ampm, " am"); } strcat(str, s); } else { // metric units itoa2(timePtr.Hour, s); strcat(str, s); } strcat(str, ":"); itoa2(timePtr.Minute, s); strcat(str, s); strcat(str, ":"); itoa2(timePtr.Second, s); strcat(str, s); strcat(str, ampm); }
/* ===================================================================*/ static void realdate2str(char* str) { char s[20]; LDD_RTC_TTime timePtr; RTC1_GetTime(NULL, &timePtr); strcpy(str, ""); if (imperialUnits) { // imperial units itoa2(timePtr.Month, s); strcat(str, s); strcat(str, "/"); itoa2(timePtr.Day, s); strcat(str, s); strcat(str, "/"); ltoa(timePtr.Year, s); strcat(str, s); } else { // metric units itoa2(timePtr.Day, s); strcat(str, s); strcat(str, "."); itoa2(timePtr.Month, s); strcat(str, s); strcat(str, "."); ltoa(timePtr.Year, s); strcat(str, s); } }
//Proceso Top int Tope(int argc, char* argv[]) { char* video= (char*)0xb8000; int proce[65]; char Mensaje [10]; int salto; int i; char a; k_clear_screen(); message("Top V1.0: Procesos y porcentaje de CPU utilizada",0,10); message("PID CPU% TTY NAME",2,0); Sti(); while(a!=68) { a=GetKey(); salto=3; for(i=0;i<65;i++) { proce[i]=0; } for(i=0;i<100;i++) { proce[last100[i]]++; } Cli(); for(i=0;i<65;i++) { PROCESS* p=GetProcessByPID(i); if(p->free==0) { itoa2(i,Mensaje); message(Mensaje,salto,0); itoa2(proce[i],Mensaje); message(Mensaje,salto,28); itoa2(p->tty,Mensaje); message(Mensaje,salto,56); message(p->name,salto,78); salto=salto+1; } message(" ",salto,0); } if (argc>1) i=atoi2(argv[1]); else i=0; Sti(); Sleep(i); } return 0; }
void display_round(){ static char buffer[2] = "--"; itoa2(get_current_work_length(), buffer); round_display_time[0] = buffer[0]; round_display_time[1] = buffer[1]; itoa2(get_current_relax_length(), buffer); round_display_time[3] = buffer[0]; round_display_time[4] = buffer[1]; text_layer_set_text(&round_layer, round_display_time); }
int main(){ char s[100]; itoa(12345, s); printf("n=%s\n", s); itoa(INT_MIN, s); printf("n_min=%s\n", s); itoa2(12345, s); printf("n2=%s\n", s); itoa2(INT_MIN, s); printf("n2_min=%s\n", s); return 0; }
void format_lap(time_t lap_time, char* buffer) { int hundredths = (lap_time / 100) % 10; int seconds = (lap_time / 1000) % 60; int minutes = (lap_time / 60000) % 60; int hours = lap_time / 3600000; itoa2(hours, &buffer[0]); buffer[2] = ':'; itoa2(minutes, &buffer[3]); buffer[5] = ':'; itoa2(seconds, &buffer[6]); buffer[8] = '.'; itoa1(hundredths, &buffer[9]); }
void CombatMode::CanContinue() { // If player is dead, the game is over if ( m_pPlayer->GetCurHP() == 0 ) { AddStringToCombatLog( "You die! Game Over " ); CGameEngine::Instance()->ContinueGame(m_pCombatant, m_pMonster); } // If enemy is dead, game continues else if ( m_pCombatant->GetCurHP() == 0 ) { AddStringToCombatLog( "You have slain " + m_pCombatant->GetName() + "!"); CGameEngine::Instance()->ContinueGame(m_pCombatant, m_pMonster); } // If it is the enemy his turn, he attacks the player else if ( !m_bPlayersTurn ) { int damage = m_pCombatant->Attack(m_pPlayer); if ( damage > 0 ) { AddStringToCombatLog( m_pCombatant->GetName() + " hits you with " + itoa2(damage) + " damage!" ); } else { AddStringToCombatLog( m_pCombatant->GetName() + " misses you! " ); } m_bPlayersTurn = true; CanContinue(); } }
const char* ApplicationLayer::Models::RollModel::GetFormattedValue() const { static char formatted[4] = { 0 }; itoa2(GetRawValue(), formatted, 10); return formatted; }
void format_seconds(int seconds, char* display_buffer){ static char buffer[2]; if (seconds > 60){ itoa2(seconds/60, buffer); display_buffer[0] = buffer[0]; display_buffer[1] = buffer[1]; seconds = seconds % 60;//removing the minutes; }else{ display_buffer[0] = '0'; display_buffer[1] = '0'; } display_buffer[2] = ':'; itoa2(seconds, buffer); display_buffer[3] = buffer[0]; display_buffer[4] = buffer[1]; }
/* * Update and redraw thumb text of autopark timeout slider. */ void update_parkbox( void ) { OBJECT *tree = (OBJECT *)rs_trindex[MACCEL]; if( dodelay ) sl_delay(); itoa2( ma_work.savepark, TedText(PARKTHUM) ); Objc_draw( tree, PARKTHUM, MAX_DEPTH, NULL ); }
int main() { int n = INT_MIN; char s[MAXLINE]; printf("%i\n",n); itoa2(n,s); printf("%s\n",s); }
void print(long num,long base,long digits) { char *ptr,buffer[128]; itoa2(num,buffer,base,&digits); ptr=buffer; while(*ptr) { putchar(*ptr++); /* Put the character out */ if(ptr[-1]=='\n') *--ptr='\r'; } }
void update_text_digits() { itoa2((round_time/1000)/60, text_digits[0]); itoa2((round_time/1000)%60, text_digits[1]); itoa2((warning_time/1000)/60, text_digits[2]); itoa2((warning_time/1000)%60, text_digits[3]); itoa2((rest_time/1000)/60, text_digits[4]); itoa2((rest_time/1000)%60, text_digits[5]); itoa2(total_round_count, round_count_digits); }
int main(void) { char line[MAX_LINE_LEN]; char a1[] = "283472"; char a2[] = "28.3472"; char num[MAX_LINE_LEN]; getline2(line); printf("%s\n", line); printf("a=%s, i=%d\n", a1, atoi2(a1)); printf("a=%s, i=%d\n", a2, atoi2(a2)); itoa2(1, num, 10); printf("%s\n", num); itoa2(12, num, 10); printf("%s\n", num); itoa2(-12, num, 10); printf("%s\n", num); char s0[] = ""; char s1[] = "1"; char s2[] = "12"; char s3[] = "123"; reverse(s0); printf("%s\n", s0); reverse(s1); printf("%s\n", s1); reverse(s2); printf("%s\n", s2); reverse(s3); printf("%s\n", s3); printf("%d\n", strindex("abc", "")); printf("%d\n", strindex("abc", "a")); printf("%d\n", strindex("abc", "c")); printf("%d\n", strindex("abc", "d")); printf("%d\n", strindex("", "abc")); printf("%d\n", strindex("a", "abc")); return 0; }
const char* ApplicationLayer::Models::VoltageModel::GetFormattedValue() const { static char formatted[5] = { 0 }; int32_t rawValue = GetRawValue(); int16_t integerPart = rawValue / 100; int16_t fractionalPart = rawValue % 100; if (integerPart > 10) { itoa2(integerPart, formatted, 10); formatted[2] = '.'; itoa2(fractionalPart, formatted + 3, 10); } else { itoa2(integerPart, formatted, 10); formatted[1] = '.'; itoa2(fractionalPart, formatted + 2, 10); } return formatted; }
/* ===================================================================*/ static void time2str(double time, char* str) { int days, rest, hours, minutes, seconds; char s[20]; days = time / (24 * 60 * 60); rest = fmod(time, 24 * 60 * 60); hours = rest / (60 * 60); rest = rest % (60 * 60); minutes = rest / 60; seconds = rest % 60; strcpy(str, ""); ltoa(days, s); strcat(str, s); strcat(str, "d "); itoa2(hours, s); strcat(str, s); strcat(str, ":"); itoa2(minutes, s); strcat(str, s); strcat(str, ":"); itoa2(seconds, s); strcat(str, s); }
bool CombatMode::Hit( const CEGUI::EventArgs &e ) { // Gives damage to the enemy int damage = m_pPlayer->Attack(m_pCombatant); if ( damage > 0 ) { // Print combat log AddStringToCombatLog( "You hit " + m_pCombatant->GetName() + " with " + itoa2(damage) + "!" ); m_pPlayer->AddRage(2); } else { AddStringToCombatLog( "You miss " + m_pCombatant->GetName() + "!" ); } m_bPlayersTurn = false; CanContinue(); return true; }
//Printf a string to the FT245. Works like printf void printf245(const char *text, ...){ char character=0, temp=0; char decimal[6]; int index=0; va_list next_argument; //Create a pointer for the variable argument va_start(next_argument, text); //Initialize the pointer to the next argument in the list setDataOutputs(); character=text[index]; while(character!='\0'){ if(USBwriteAllowed()){ if(character=='%'){ //Need to access an argument value! character = (char)va_arg(next_argument, int); //Get the value of the current argument if(text[index+1]=='d'){ itoa2(character, decimal); for(int i=0; decimal[i]!='\0'; i++)printf245("%c", decimal[i]); index+=1; } else if(text[index+1]=='x'){ temp=character; temp=temp>>4; if(temp>9)temp+=('A'-10); else temp+='0'; printf245("%c", temp); character=character&0x0f; if(character>9)character+=('A'-10); else character+='0'; printf245("%c", character); index+=1; } else if(text[index+1]=='c'){ PORTD = character; clearWR(); delay_ms(1); setWR(); index+=1; } }
void sl_x( int base, int value, int min, int max ) { OBJECT *tree = rs_object; int slider = ObHead(base); if( value == max ) { ObX(slider) = ObW(base) - ObW(slider); } else { ObX(slider) = (int)( ( (long)(value-min) * ( (long)(ObW(base) - ObW(slider)) * 1000L ) ) / ( (long)(max-min) * 1000L ) ); } if( max < 10 ) TedText(slider)[0] = '0' + value; else itoa2( value, TedText(slider) ); }
void itoa2(int n, char s[], int pos) { int sign, i; i = pos; if (n < 0) sign = -n; else sign = n; s[i] = (sign % 10) + '0'; if(sign / 10) itoa2((n / 10), s, i + 1); else { if(n < 0) s[++i] = '-'; s[++i] = '\0'; } if(pos == 0) { reverse(s); } }
int reverseBit(int a) { char s[100]; itoa2(a,s,2); int len = 0; while( s[len] ) { len ++; } int i; for( i=0; i<len/2; i++ ) { char temp = s[i]; s[i] = s[len-i-1]; s[len-i-1] = temp; } int ret = TwoToTen(s); return ret; }
// Called once per minute void handle_minute_tick(AppContextRef ctx, PebbleTickEvent *t) { (void)t; (void)ctx; static char wifeText[] = "Karolina is weeks pregnant."; static char weekText[] = "XX"; static char papaText[] = " The baby is the"; static char compText[] = " "; static char fruitText[] = " "; int weeks = get_weeks(); itoa2(get_weeks(), &weekText[0]); replacetxt(comparisons[weeks],&compText[0]); replacetxt(fruits[weeks],&fruitText[0]); text_layer_set_text(&wifeLayer,wifeText); text_layer_set_text(&weekLayer,weekText); text_layer_set_text(&papaLayer,papaText); text_layer_set_text(&compLayer,compText); text_layer_set_text(&fruitLayer,fruitText); }
bool CombatMode::Double( const CEGUI::EventArgs &e ) { // Checks for enough rage and if so, attack with double slash if ( m_pPlayer->GetRage() > 8 ) { int damage = m_pPlayer->DoubleSlash(m_pCombatant); if ( damage > 0 ) { AddStringToCombatLog( "You Double Slash " + m_pCombatant->GetName() + " with " + itoa2(damage) + "!!!" ); } else { AddStringToCombatLog( "You miss " + m_pCombatant->GetName() + "!" ); } m_bPlayersTurn = false; CanContinue(); } else { AddStringToCombatLog( "You don't have enough Rage!\n Need at least 6 for Double Slash!" ); } return true; }
bool CombatMode::Thunder( const CEGUI::EventArgs &e ) { // Checks for enough rage and if so, attack with thunder if ( m_pPlayer->GetRage() > 4 ) { int damage = m_pPlayer->ThunderStrike(m_pCombatant); if ( damage > 0 ) { AddStringToCombatLog( "You ThunderStrike " + m_pCombatant->GetName() + " with " + itoa2(damage) + "!!" ); } else { AddStringToCombatLog( "You miss " + m_pCombatant->GetName() + "!" ); } m_bPlayersTurn = false; CanContinue(); } else { AddStringToCombatLog( "You don't have enough Rage!\n Need at least 3 for ThunderStrike!" ); } return true; }
/* * CPX user interaction */ BOOLEAN cdecl cpx_call( GRECT *rect ) { OBJECT *tree = (OBJECT *)rs_trindex[MACCEL]; int button; int quit = 0; int saveptime; WORD msg[8]; MA_INFO *src; int ox, oy; MRETS mk; if( !ma_installed ) { form_alert( 1, alertbox ); return FALSE; } ma_work = ma_cancel = *ma_info; ObX( ROOT ) = rect->g_x; ObY( ROOT ) = rect->g_y; set_accelbox( tree, ma_info->linear ); set_screenbox( tree, ma_info->udset ); ma_work.timeout /= 3600; ma_cancel.timeout /= 3600; xcpb->Sl_x( tree, SCRNBACK, SCRNTHUM, ma_work.timeout, SCRN_MIN, SCRN_MAX, NULLFUNC ); TedText(SCRNTHUM)[0] = '0' + ma_work.timeout; if( ma_info->watch ) Select(PHONE); else Deselect(PHONE); if( ma_info->stacy ) { ObFlags(STACSCRN) = ObFlags(STACLITE) = TOUCHEXIT; if( ma_info->stacmask & SH_SCREEN ) Select( STACSCRN ); if( ma_info->stacmask & SH_LIGHT ) Select( STACLITE ); } else { ObFlags(STACSCRN) = ObFlags(STACLITE) = NONE; ObState(STACSCRN) = ObState(STACLITE) = DISABLED; /* deselects */ } Supexec( (long(*)())get_ptime ); saveptime = ma_work.savepark = parktime; if( saveptime == 0 ) saveptime = 1; set_parkbox( tree ); if( parktime >= 0 ) { xcpb->Sl_x( tree, PARKBACK, PARKTHUM, parktime, PARK_MIN, PARK_MAX, NULLFUNC ); itoa2( ma_work.savepark, TedText(PARKTHUM) ); } Objc_draw( tree, ROOT, MAX_DEPTH, NULL ); do { dodelay = FALSE; sl_time = SL_MAX_DELAY; button = xcpb->Xform_do( tree, 0, msg ); if( button == -1 ) if( msg[0] == AC_CLOSE ) button = CANCEL; else if( msg[0] == WM_CLOSED ) button = OK; else button &= 0x7fff; switch( button ) { case OK: src = &ma_work; update_info( tree, src ); quit = OK; break; case CANCEL: src = &ma_cancel; quit = CANCEL; break; case SAVE: if( xcpb->XGen_Alert( SAVE_DEFAULTS ) ) { src = &ma_work; update_info( tree, src ); src->timeout *= 3600; if( xcpb->CPX_Save( src, sizeof(MA_INFO) ) ) { set_info( ma_info, src ); src->timeout /= 3600; ma_cancel = ma_work; } else { src->timeout /= 3600; } } deselect( tree, SAVE ); break; case OFF: ma_work.linear = ma_info->linear = -1; break; case SLOW: ma_work.linear = ma_info->linear = 1; break; case FAST: ma_work.linear = ma_info->linear = 0; break; case PARK: if( IsSelected(PARK) ) /* deselecting */ { saveptime = ma_work.savepark; ma_work.savepark = 0; } else { ma_work.savepark = saveptime; xcpb->Sl_x( tree, PARKBACK, PARKTHUM, parktime, PARK_MIN, PARK_MAX, update_parkbox ); } set_parkbox( tree ); Objc_draw( tree, PARKBOX, MAX_DEPTH, NULL ); break; case PARKUP: dodelay = TRUE; xcpb->Sl_arrow( tree, PARKBACK, PARKTHUM, PARKUP, 1, PARK_MIN, PARK_MAX, &ma_work.savepark, HORIZONTAL, update_parkbox ); break; case PARKDN: dodelay = TRUE; xcpb->Sl_arrow( tree, PARKBACK, PARKTHUM, PARKDN, -1, PARK_MIN, PARK_MAX, &ma_work.savepark, HORIZONTAL, update_parkbox ); break; case PARKTHUM: xcpb->Sl_dragx( tree, PARKBACK, PARKTHUM, PARK_MIN, PARK_MAX, &ma_work.savepark, update_parkbox ); break; case PARKBACK: dodelay = TRUE; Graf_mkstate( &mk ); objc_offset( tree, PARKTHUM, &ox, &oy ); if( mk.x < ox ) oy = -PARK_PAGE; else oy = PARK_PAGE; xcpb->Sl_arrow( tree, PARKBACK, PARKTHUM, -1, oy, PARK_MIN, PARK_MAX, &ma_work.savepark, HORIZONTAL, update_parkbox ); break; case SCRN: ma_work.udset ^= 1; set_screenbox( tree, ma_work.udset ); Objc_draw( tree, SCRNBOX, MAX_DEPTH, NULL ); break; case SCRNUP: dodelay = TRUE; xcpb->Sl_arrow( tree, SCRNBACK, SCRNTHUM, SCRNUP, 1, SCRN_MIN, SCRN_MAX, &ma_work.timeout, HORIZONTAL, update_screenbox ); break; case SCRNDN: dodelay = TRUE; xcpb->Sl_arrow( tree, SCRNBACK, SCRNTHUM, SCRNDN, -1, SCRN_MIN, SCRN_MAX, &ma_work.timeout, HORIZONTAL, update_screenbox ); break; case SCRNTHUM: xcpb->Sl_dragx( tree, SCRNBACK, SCRNTHUM, SCRN_MIN, SCRN_MAX, &ma_work.timeout, update_screenbox ); break; case SCRNBACK: dodelay = TRUE; Graf_mkstate( &mk ); objc_offset( tree, SCRNTHUM, &ox, &oy ); if( mk.x < ox ) oy = -SCRN_PAGE; else oy = SCRN_PAGE; xcpb->Sl_arrow( tree, SCRNBACK, SCRNTHUM, -1, oy, SCRN_MIN, SCRN_MAX, &ma_work.timeout, HORIZONTAL, update_screenbox ); break; } } while (!quit); Deselect(quit); src->timeout *= 3600; set_info( ma_info, src ); return FALSE; }
int32_t vsprintf(char *s, const char *fmt, va_list args) { char *str; for(str = s; *fmt != '\0'; ++fmt) { // Simply copy character to buffer if not a format specifier if(*fmt != '%') { *str++ = *fmt; continue; } uint8_t flags = 0; uint32_t width = 0; int32_t precision = -1; uint8_t length; char specifier = 0; // First come the flags. Get all flags specified ++fmt; for(bool i = false; i != true;) { switch(*fmt) { case '-': flags |= LEFTJUSTIFY; ++fmt; break; case '+': flags |= PLUS; ++fmt; break; case ' ': flags = (flags & PLUS) ? flags : flags|SPACE; ++fmt; break; case '#': flags |= SPECIAL; ++fmt; break; case '0': flags |= ZEROPAD; ++fmt; break; default: i = true; break; } } // Next up is width sub specifier if(*fmt == '*') { // Next arg is the width sub specifier width = va_arg(args, uint32_t); ++fmt; } else if(is_number(*fmt)) { // Convert the string into a number size_t num = num_digits(fmt); width = atoi(fmt); fmt += num; } else { // Otherwise there is no width, turn of ZEROPAD and LEFTJUSTIFY width = 0; flags &= ~(ZEROPAD | LEFTJUSTIFY); } if(*fmt == '.') { // A precision has been specified ++fmt; if(*fmt == '*') { // Next arg is precision value, set ZEROPAD flag precision = va_arg(args, uint32_t); ++fmt; } else if(is_number(*fmt)) { // Convert string to number, set ZEROPAD flag size_t num = num_digits(fmt); precision = atoi(fmt); fmt += num; } else { // Otherwise no precision has been specified precision = 0; } } // Determine length sub specifier if there is one switch(*fmt) { case 'h': // Check if next character is h ++fmt; if(*fmt == 'h') { length = _hh; ++fmt; } else { length = _h; } break; case 'l': // Check if next character is l ++fmt; if(*fmt == 'l') { length = _ll; ++fmt; } else { length = _l; } break; case 'j': ++fmt; length = _j; break; case 'z': ++fmt; length = _z; break; case 't': ++fmt; length = _t; break; default: break; } // Now we can check for the specifier character and do the deeds switch(*fmt) { case 'd': case 'i': { specifier = 'd'; int32_t num = va_arg(args, int32_t); bool negative = false; char str_num[32]; if(precision == 0 && num == 0) break; if(num < 0) { negative = true; num *= -1; } itoa2(num, str_num, 10, false); number(fmt_num, str_num, flags, width, precision, negative, specifier); size_t len = strlen(fmt_num); for(uint32_t i = 0; i < len; i++) *str++ = fmt_num[i]; break; } case 'u': { specifier = 'u'; uint32_t num = va_arg(args, uint32_t); char str_num[32]; if(precision == 0 && num == 0) break; itoa2(num, str_num, 10, false); number(fmt_num, str_num, flags, width, precision, false, specifier); size_t len = strlen(fmt_num); for(uint32_t i = 0; i < len; i++) *str++ = fmt_num[i]; break; } case 'o': { specifier = 'o'; int32_t num = va_arg(args, int32_t); bool negative = false; char str_num[32]; if(precision == 0 && num == 0) break; if(num < 0) { negative = true; num *= -1; } itoa2(num, str_num, 8, false); number(fmt_num, str_num, flags, width, precision, negative, specifier); size_t len = strlen(fmt_num); for(uint32_t i = 0; i < len; i++) *str++ = fmt_num[i]; break; } case 'x': specifier = 'x'; case 'X': { bool upcase = true; if(specifier == 'x') upcase = false; else specifier = 'X'; uint32_t num = va_arg(args, uint32_t); bool negative = false; char str_num[32]; if(precision == 0 && num == 0) break; itoa2(num, str_num, 16, upcase); number(fmt_num, str_num, flags, width, precision, negative, specifier); size_t len = strlen(fmt_num); for(uint32_t i = 0; i < len; i++) *str++ = fmt_num[i]; break; } case 'c': specifier = 'c'; case 's': { flags &= ~(PLUS | SPACE | SPECIAL | ZEROPAD); if(specifier == 'c') { uint32_t c_int = va_arg(args, uint32_t); char c[2]; c[0] = (char)c_int; c[1] = '\0'; precision = -1; number(fmt_num, c, flags, width, precision, false, specifier); } else { specifier = 's'; char *string = va_arg(args, char*); number(fmt_num, string, flags, width, precision, false, specifier); } size_t len = strlen(fmt_num); for(uint32_t i = 0; i < len; i++) *str++ = fmt_num[i]; break; } case 'p': { specifier = 'p'; uintptr_t num = va_arg(args, uintptr_t); char str_num[32]; itoa2(num, str_num, 16, false); number(fmt_num, str_num, flags, width, precision, false, specifier); size_t len = strlen(fmt_num); for(uint32_t i = 0; i < len; i++) *str++ = fmt_num[i]; break; } case 'n': { specifier = 'n'; int32_t *n = va_arg(args, int32_t*); *n = (int32_t)(str-s); break; } case 'f': { specifier = 'f'; double num = va_arg(args, double); char str_num[32]; uint32_t whole = (uint32_t)num; itoa2(whole, str_num, 10, false); size_t len = strlen(str_num); for(uint32_t i = 0; i < len; i++) *str++ = str_num[i]; uint32_t pow10 = 10; for(int32_t i = precision; i > 0; i--) { pow10 *= pow10; } double frac_part = num - (double)((uint32_t)num); uint32_t frac = (precision > 6) ? (uint32_t)(frac_part * (double)pow10) : (uint32_t)(frac_part * (double)1000000); if(frac == 0 && (flags & SPECIAL)) { *str++ = '.'; *str++ = '0'; } else { *str++ = '.'; memset(str_num, 32, 0); itoa2(frac, str_num, 10, false); number(fmt_num, str_num, flags, width, precision, false, specifier); len = strlen(fmt_num); for(uint32_t i = 0; i < len; i++) *str++ = fmt_num[i]; } break; } case '%': { specifier = '%'; char c[2]; c[0] = '%'; c[1] = '\0'; flags &= ~(PLUS | SPACE | SPECIAL | ZEROPAD); precision = -1; number(fmt_num, c, flags, width, precision, false, specifier); size_t len = strlen(fmt_num); for(uint32_t i = 0; i < len; i++) *str++ = fmt_num[i]; break; } default: break; } } *str = '\0'; return(str-s); }
bool CCore::SystemsInit() { m_bRunningValid = false; CLogManager::Instance()->LogMessage("Initializing engine."); unsigned int seed = (unsigned int)time(NULL); CLogManager::Instance()->LogMessage("Seeding game: " + itoa2(seed)); srand( seed ); CGameSettings::Instance(); // Initialize SDL if (SDL_Init(SDL_INIT_EVERYTHING) < 0) return false; // Initialize renderer m_pRenderer = CRenderer::Instance(); if ( !m_pRenderer->Init() ) return false; // Initialize resource manager m_pResourceManager = CResourceManager::Instance(); // Initialize particle system manager m_pParticleSystemManagerNear = CParticleSystemManager::InstanceNear(); m_pParticleSystemManagerFar = CParticleSystemManager::InstanceFar(); // Initialize wiimote manager m_pWiimoteManager = CWiimoteManager::Instance(); // Initialize ODE m_pODEManager = CODEManager::Instance(); // Initialize sound m_pSoundManager = CSoundManager::Instance(); if ( !m_pSoundManager->Init() ) return false; CLoadingScreen::Instance()->Init(); // Initialize active state m_bMenu = SETS->MENU_ON; if ( m_bMenu ) { m_iLastAmountOfPlayers = 1; m_pActiveState = new CMenuState(); } else { CLoadingScreen::Instance()->StartRendering(); m_pActiveState = new CGameState(); ((CGameState *)m_pActiveState)->Init( SETS->PLAYERS ); CLoadingScreen::Instance()->StopRendering(); m_szLastPlayedLevel = SETS->LEVEL; m_iLastAmountOfPlayers = SETS->PLAYERS; } m_bRunningValid = true; m_pWiimoteManager->RegisterListener( m_pActiveState, -1 ); // All systems go! CLogManager::Instance()->LogMessage("Initializion succesful."); return true; }
int main() { int i, j, b, l; char a[MAXSTRING]; i = 25; itoa(i, a); printf("itoa(%d, a) = %s\n", i, a); i = -13; itoa(i, a); printf("itoa(%d, a) = %s\n", i, a); b = 2; i = 27; itob(i, a, b); printf("itob(%d, a, %d) = %s\n", i, b, a); b = 16; itob(i, a, b); printf("itob(%d, a, %d) = %s\n", i, b, a); i = 27; l = 0; itoa2(i, a, l); printf("itoa2(%d, a, %d) = %s, strlen(a) = %d\n", i, l, a, strlen(a)); l = 4; itoa2(i, a, l); printf("itoa2(%d, a, %d) = %s, strlen(a) = %d\n", i, l, a, strlen(a)); l = 15; itoa2(i, a, l); printf("itoa2(%d, a, %d) = %s, strlen(a) = %d\n", i, l, a, strlen(a)); return 0; }