Communities

Writing
Writing
Codidact Meta
Codidact Meta
The Great Outdoors
The Great Outdoors
Photography & Video
Photography & Video
Scientific Speculation
Scientific Speculation
Cooking
Cooking
Electrical Engineering
Electrical Engineering
Judaism
Judaism
Languages & Linguistics
Languages & Linguistics
Software Development
Software Development
Mathematics
Mathematics
Christianity
Christianity
Code Golf
Code Golf
Music
Music
Physics
Physics
Linux Systems
Linux Systems
Power Users
Power Users
Tabletop RPGs
Tabletop RPGs
Community Proposals
Community Proposals
tag:snake search within a tag
answers:0 unanswered questions
user:xxxx search by author id
score:0.5 posts with 0.5+ score
"snake oil" exact phrase
votes:4 posts with 4+ votes
created:<1w created < 1 week ago
post_type:xxxx type of post
Search help
Notifications
Mark all as read See all your notifications »

Welcome to Software Development on Codidact!

Will you help us build our independent community of developers helping developers? We're small and trying to grow. We welcome questions about all aspects of software development, from design to code to QA and more. Got questions? Got answers? Got code you'd like someone to review? Please join us.

Review Suggested Edit

You can't approve or reject suggested edits because you haven't yet earned the Edit Posts ability.

Approved.
This suggested edit was approved and applied to the post about 3 years ago by dumplings‭.

33 / 255
Regarding the implementation of data structures.
  • Hi, I'm attempting a question to do with data structures, file streams & linked lists.
  • > Nvm I solved it :)
  • aBook.title = ""; //how should I write in the double quotes?
  • aBook.author = "";
  • aBook.subject = "";
  • ![Question Part 1](https://software.codidact.com/uploads/wxoGToBH6tVpJFBLwBv7P566)
  • Hi, I'm attempting a question to do with data structures, file streams & linked lists. The code isn't complete yet as I am still halfway working on it. I am required to use data structures in the declaration section like so as shown in my code below. However, I'm still confused on what I should include in the double quotes for aBook.title, aBook.author & aBook.subject (I'm not sure if I'm doing it right too). Can anyone help me out? thanks~ (Also my title, author and book should not exceed 49 characters)
  • ```
  • #include<stdio.h>
  • #include<stdlib.h>
  • //#define MAX 49
  • int main (void){
  • FILE *cfPtr;
  • struct book{ //the data structure that I am required to use
  • char *title;
  • char *author;
  • char *subject; //subject[]
  • };
  • int operation;
  • if ((cfPtr = fopen("library.dat","w")) == NULL){
  • printf("File could not be opened...\n");
  • }
  • else {
  • struct book aBook;
  • struct book *aPtr;
  • aBook.title = ""; //how should I write in the double quotes?
  • aBook.author = "";
  • aBook.subject = "";
  • printf("Enter operation number:");
  • scanf("%d", &operation)
  • switch(operation){
  • case 1:
  • printf("Title:\n");
  • scanf("%s", title);
  • printf("Author:");
  • scanf("%s", author);
  • printf("Subject:");
  • scanf("%s", subject);
  • break;
  • case 2:
  • printf("Enter Title:");
  • scanf("%s", Title);
  • //Incomplete coding (still working on it)
  • //I'm planning to use switch case by looking at the question but I also have to use linked lists
  • fprintf(cfPtr, "%s %s %s\n", title, author, subject);
  • }
  • fclose(cfPtr);
  • return 0;
  • }

Suggested about 3 years ago by Canina‭