I want to make a program that when the user enters AB1245 and have the program change it to AB 12345 (an added space between 2nd and 3rd character)
char Bilnr[9];
for (i = 8; i < 3; i--) {
Bilnr[i++]=Bilnr[i];
}
As I understand this, this program will start with Bilnr[9] and set it to the value of Bilnr[8].
Then set Bilnr[8] to the value of Bilnr[7].
But it doesn’t move any of the values. It simply prints AB1245.
One thing I notice is that if your loop ever actually executes, it would be infinite
I++doesn’t meanI+1rather, it meansI = I+1but your loop won’t execute, because your condition,
I<3will be false from the get-go when you initializeIwithI=8You’re also never setting
I[2]to be a' 'you also also have to realize that arrays start at
0, soBilnr[0]=='A'try