前提・実現したいこと
c言語です。
ランダムで表示した0-99の数値をひらがな読みにしたいです。
発生している問題・エラーメッセージ
エラーメッセージ ```main.c: In function ‘main’: main.c:13:16: warning: assignment to ‘char’ from ‘char *’ makes integer from pointer without a cast [-Wint-conversion] 13 | result2="ぜろ"; | ^ main.c:15:16: warning: assignment to ‘char’ from ‘char *’ makes integer from pointer without a cast [-Wint-conversion] 15 | result1="じゅう"; | ^ main.c:17:16: warning: assignment to ‘char’ from ‘char *’ makes integer from pointer without a cast [-Wint-conversion] 17 | result1="にじゅう"; | ^ main.c:19:16: warning: assignment to ‘char’ from ‘char *’ makes integer from pointer without a cast [-Wint-conversion] 19 | result1="さんじゅう"; | ^ main.c:21:16: warning: assignment to ‘char’ from ‘char *’ makes integer from pointer without a cast [-Wint-conversion] 21 | result1="よんじゅう"; | ^ main.c:23:16: warning: assignment to ‘char’ from ‘char *’ makes integer from pointer without a cast [-Wint-conversion] 23 | result1="ごじゅう"; | ^ main.c:25:16: warning: assignment to ‘char’ from ‘char *’ makes integer from pointer without a cast [-Wint-conversion] 25 | result1="ろくじゅう"; | ^ main.c:27:16: warning: assignment to ‘char’ from ‘char *’ makes integer from pointer without a cast [-Wint-conversion] 27 | result1="ななじゅう"; | ^ main.c:29:16: warning: assignment to ‘char’ from ‘char *’ makes integer from pointer without a cast [-Wint-conversion] 29 | result1="はちじゅう"; | ^ main.c:31:16: warning: assignment to ‘char’ from ‘char *’ makes integer from pointer without a cast [-Wint-conversion] 31 | result1="きゅうじゅう"; | ^ main.c:35:16: warning: assignment to ‘char’ from ‘char *’ makes integer from pointer without a cast [-Wint-conversion] 35 | result1="いち"; | ^ main.c:37:16: warning: assignment to ‘char’ from ‘char *’ makes integer from pointer without a cast [-Wint-conversion] 37 | result2="に"; | ^ main.c:39:16: warning: assignment to ‘char’ from ‘char *’ makes integer from pointer without a cast [-Wint-conversion] 39 | result2="さん"; | ^ main.c:41:16: warning: assignment to ‘char’ from ‘char *’ makes integer from pointer without a cast [-Wint-conversion] 41 | result2="よん"; | ^ main.c:43:16: warning: assignment to ‘char’ from ‘char *’ makes integer from pointer without a cast [-Wint-conversion] 43 | result2="ご"; | ^ main.c:45:16: warning: assignment to ‘char’ from ‘char *’ makes integer from pointer without a cast [-Wint-conversion] 45 | result2="ろく"; | ^ main.c:47:16: warning: assignment to ‘char’ from ‘char *’ makes integer from pointer without a cast [-Wint-conversion] 47 | result2="なな"; | ^ main.c:49:16: warning: assignment to ‘char’ from ‘char *’ makes integer from pointer without a cast [-Wint-conversion] 49 | result2="はち"; | ^ main.c:51:16: warning: assignment to ‘char’ from ‘char *’ makes integer from pointer without a cast [-Wint-conversion] 51 | result2="きゅう"; | ^ main.c:56:1: error: expected declaration or statement at end of input 56 | } | ^ ### 該当のソースコード ```c言語 ソースコード ```#include<stdio.h> #include<stdbool.h> #include<stdlib.h> #include<time.h> int main(void){ srand(time(NULL)); int x=rand()%99; int y=x/10; int z=x-y*10; char result1; char result2; if(y==0&&z==0){ result2="ぜろ"; if(y==1){ result1="じゅう"; }else if(y==2){ result1="にじゅう"; }else if(y==3){ result1="さんじゅう"; }else if(y==4){ result1="よんじゅう"; }else if(y==5){ result1="ごじゅう"; }else if(y==6){ result1="ろくじゅう"; }else if(y==7){ result1="ななじゅう"; }else if(y==8){ result1="はちじゅう"; }else if(y==9){ result1="きゅうじゅう"; } if(z==1){ result1="いち"; }else if(z==2){ result2="に"; }else if(z==3){ result2="さん"; }else if(z==4){ result2="よん"; }else if(z==5){ result2="ご"; }else if(z==6){ result2="ろく"; }else if(z==7){ result2="なな"; }else if(z==8){ result2="はち"; }else if(z==9){ result2="きゅう"; } printf("%c%c",result1,result2); return 0; } ### 試したこと =変えたりしてみましたが変数ポインターの処理 ここに問題に対して試したことを記載してください。 ### 補足情報(FW/ツールのバージョンなど) ここにより詳細な情報を記載してください。
回答2件
あなたの回答
tips
プレビュー