hi,i have trouble when deleting one character from array of characters.please help.
Example char myNumbers[]={'1','2','3','4'};
I want to delete last character and remain with 12 and 3
myNumbers to be 1,2,and 3
When is your assignment due?
Am working on a project and am new to Arduino programming.
If you want to truncate a cstring all you need to do is write a '\0' character in the space after the last character you want to keep. With your example
char myNumbers[]={'1','2','3','4'};
you would do
myNumbers[3] = '\0';
Taking out (say) the '2' and closing the gap so you have "134" will be more complex and requires iterating over the characters 3 and 4 and copying them one by one into the preceding slot.
...R
Or, perhaps, the whole element has to be removed from the array. In which case you just copy the elements you want to keep into a new array (or you compact the array shifting the elements that should remain back in the place of the one to go).
The requirement is ambiguous and not well defined.
If numbers appear twice or more in the array, should all occurrences be deleted?
Thanks alot , i have one more question, how can i combine two integers to get one example
i have my 1st integer as int a =10 and 2nd as int b=15, i want to combine them to one integer and get 1015 i.e
int c=1025 ???
a*100+b
works as long as a and b have a value of 10-99.
use if statements to check the size of b if needed.
cant one use struct and if so how are structs used?
How do you think a struct can be of use in this context?