Collectives™ on Stack Overflow
Find centralized, trusted content and collaborate around the technologies you use most.
Learn more about Collectives
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
Learn more about Teams
*pst = queue[qNumber];
printf("Enter identifier: \n");
// assigning the identifier as an element in the queue array
scanf("%d", &queue[qNumber].id);
Once i enter the queue number,i am prompted with:
Process finished with exit code -1073741819 (0xC0000005),
when i should be asked to enter queue identifier.
queue is a struct array of size 10, and id is of type int, inside the main struct.
–
*pst = queue[qNumber];
should be
pst = &queue[qNumber];
.
queue
is an array of structures and
pst
is a pointer to such a structure. So you must place the address of the queueu structure in
pst
.
Writing
*pst = queue[qNumber];
is correct and would mean to assign the data of the queue element to what
pst
is pointing to. However,
pst
is not pointing anywhere (it is still 0).
See also the comment of Ctx about checking that a valid number was read.
Thanks for contributing an answer to Stack Overflow!
-
Please be sure to
answer the question
. Provide details and share your research!
But
avoid
…
-
Asking for help, clarification, or responding to other answers.
-
Making statements based on opinion; back them up with references or personal experience.
To learn more, see our
tips on writing great answers
.