#include<stdio.h> int main(void) { int u=0; int x; int y; int z; printf("足したい整数の数を入力して下さい:"); scanf("%d",&x); for(y=1;y<=x;y++) { printf("No.%d:",y); scanf("%d",&z); u+=z; } printf("%d\n",u); return(0); }
これでいんだよね? でも参考書には
#include<stdio.h> int main(void) { int u=0; int x; int y; int z; printf("足したい整数の数を入力して下さい:"); scanf("%d",&x); for(y=1;y<=x;y++) { printf("No.%d:",y+1); scanf("%d",&z); u+=z; } printf("%d\n",u); return(0); }
質問です。 それぞれテキスト領域、初期化データ領域、bss領域、スタック領域のどれに格納されるのでしょうか。 1.外部変数 2.関数内でstatic int hoge = 1; 3.関数内でstatic int hoge; 4.関数外でstatic int hoge = 1; 4.関数外でstatic int hoge;
for (;;) { /* This code is arranged to give in-line flow to the most frequent * case, literal transcription from *formP to *outP. */ if ((fc = *formP++) == _TEXT('\0')) goto respond; /* end of format string */ if (fc == _TEXT('%')) /* '%' char begins a conversion */ { if ((fc = *formP) == _TEXT('%')) formP++; /* but "%%" is just a literal '%'. */ else break; } PutToS(fc,&put); /* copy literal character */ }
自分で書いたものと、コンパイルエラー表示は以下です。 ================================= #include <stdio.h> #include <stdlib.h> int main(void){ FILE *fp; int da[i]; double hi[i]; double lo[i]; int i, j, max, min;
if ((fp = fopen("Temp.dat","r"))==NULL) { printf("file open error!!\n"); exit(1); }
fscanf(fp)"%d %lf %lf",&d, &f, &g";
for (i = 0; i < (n-1); ++i) { x = data[i]; max = i; for (j = i + 1; j < n; j++) { if (data[max] < data[j]) { max = j; } } printf("最高気温, 日付=%d\n, %d\n" hi[max], max);
for (i = 0; i < (n-1); ++i) { x = data[i]; min = i; for (j = i + 1; j < n; j++) { if (data[min] > data[j]) { min = j; } } printf("最低気温, 日付=%d\n, %d\n" low[min], min);
fclose(fp); }
9-1.c:40:35: missing terminating " character 9-1.c:17:34: possible start of unterminated string literal 9-1.c:36:35: missing terminating " character 9-1.c:13:34: possible start of unterminated string literal