1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

自分専用の文字列の数字を整数の数字に変換する(知っていると思うけど)

Last updated at Posted at 2025-04-18
  • UNO 等 小規模マイコンには、atoiがなぜか、無いので?
  • UNO での 予定は、未定

プログラム

オンラインコンパイラpaiza


#include <iostream>
using namespace std;

int myatoi(char *str){
    int num = 0;
    while(*str != '\0'){
        num += *str - '0';
        num *= 10;
        str++;
    }
    num /= 10;
    return(num);
}

int main(void){
    // Your code here!
    printf("%d\n",myatoi("1234"));
}



1234

1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?