Vote count:
0
So I'm writing this program on linked list that reverse the user input, but I'm a bit lost whether is it possible to come up a loop invariants for types of loop where it doesn't return any value? For example a loop that is located inside main.
Here's an example of a loop to get user input inside main and store it in a linked list
int main(void){
char c = ' ';
Node* start = NULL;
Node* temp;
while(c!='.'){
c=getchar();
temp=(Node*)calloc(1, sizeof(Node));
temp->x = c;
temp->next = start;
start = temp;
}
Is it possible to come up with a loop invariant for this? Also what does it mean by program correctness and how do I proof it in my case?
Thanks!
asked 21 secs ago
Loop invariant with no return value, is it possible? And program correctness
Aucun commentaire:
Enregistrer un commentaire