我想在C中填充2d數組一切正常,但分配給數組的值不打印。輸入驗證分配和顯示,如果二維字符數組
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#include <string.h>
main()
{
char parkingspace[25][4];
char CarReg[7], validreg[7];
int row, position;
printf("Enter the car Registration number \n");
fgets(CarReg, sizeof(CarReg), stdin);
if(isdigit(CarReg[0])&& isdigit(CarReg[1]) && (CarReg[2]=='H') && (CarReg[3]=='I') && (CarReg[4]=='R') && (CarReg[5]=='E'))
{
puts("Valid Registration \n");
printf("==================================================\n\n\n");
}
else
{
puts("Invalid registration .\n Please put a value of two digits followed by the word HIRE! in caps");
}
printf("You entered: %s\n", CarReg);
if(isdigit(CarReg[0])&& isdigit(CarReg[1]) && (CarReg[2]=='H') && (CarReg[3]=='I') && (CarReg[4]=='R') && (CarReg[5]=='E'))
{
strcpy(validreg, CarReg);
printf("Accepted Car Reg is : %s\n\n\n\n", validreg);
printf("==================================================\n\n\n");
}
for (row=1; row<26; row++)
{
for (position=1;position<5; position++)
{
parkingspace[row][position]=validreg;
printf("parkingspace \t row[%d] position[%d] =[ %c ]\n", row,position,parkingspace[row][position]);
}
}
}
你忘了添加代碼 – 2013-03-06 11:38:33
您忘記了密碼... – 2013-03-06 11:38:33
你還指望它來打印,它有什麼打印 – 2013-03-06 11:41:16