添加链接
link之家
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接
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.

You absolutely have to make sure that a) the conversion of qNumber actually succeeds (return value of scanf() has to be 1, otherwise qNumber remains 0), and that the resulting number of qNumber is inside the bounds of the array queue . Ctx Jan 7, 2020 at 13:58

*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 .