printf は次のようになります。
printf("%s type\n", a[x]);
配列の要素は文字列であるためです。
printf
出力の上のようにステートメントを変更した後:
出力:
Tires type
Lights type
Seats type
必要に応じて、追加\n
した のを削除できます。printf
その場合の出力は次のとおりです。
Tires typeLights typeSeats type
これが私のコードです:(タイヤはこのインプリメンテーションで表示されるはずです)
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main(){
int x = 0;
char a[3][20];
strcpy(a[0], "Tires");
strcpy(a[1], "Lights");
strcpy(a[2], "Seats");
while(1) // i left in this while as may be using it for something that you haven't shown in your code.
{ // But if you are not using while get rid of it .. its unnecessary
for(x = 0; x< 3; x++)
{
printf("%s type\n", a[x]);
}
break;
}
return 0;
}
このコードの実行方法は次のとおりです。
Notra:Desktop Sukhvir$ gcc -Werror -Wall -g -o try try.c -std=c99
Notra:Desktop Sukhvir$ ./try
Tires type
Lights type
Seats type