I've been trying to insert an element into an array with little success. I've been able to find similar examples but am still unable to get my code to work. So any help would be appreciated.
The aim of the function is to check a phone number for a space as the fifth digit and insert one if it doesn't exist. The code below doesn't compile (error below). All I am trying to achieve at the moment is to change the 5th digit without dealing with shifting the other elements within the array.
Error message :Code:/* Pass in the phone number, check there is a space in position 5 and insert if not present. */ void ValidatePhoneNumber(char *phoneNumber) { if(&phoneNumber[5] != " ") { &phoneNumber[5] = " "; } }
In file included from driver.c:1:
validation.h: In function ‘ValidatePhoneNumber’:
validation.h:51: error: lvalue required as left operand of assignment
Thanks in adance for any help / guidance