3www2as3com0
に変換するプログラムを作りたいのですがwww.as.com
、最初はうまくいきませんでした。文字列の最初の数字 (文字 3) を整数に変換して、変換したプログラムを印刷するときに3 ではなく 51 を表示するなどの関数を使用したいと考えています。問題は何ですかstrncpy
?strchr
int
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main(int argc, char** argv) {
/* argv[1]--->3www2as3com0*/
char *string;
char *p;
string=argv[1];
p=string;
char cond,cond2;
cond=*p; //I want to have in cond the number 3
cond2=(int)cond; //I want to convert cond (a char) to cond2(an int)
printf("%d",cond2); //It print me 51 instead of 3
return (EXIT_SUCCESS);
}