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 »
Q&A

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.

Post History

33%
+2 −6
Q&A Regarding the implementation of data structures.

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

1 answer  ·  posted 2y ago by dumplings‭  ·  edited 2y ago by Alexei‭

#13: Post edited by user avatar Alexei‭ · 2022-06-26T16:39:47Z (almost 2 years ago)
rolled back to a version that contains the code
  • I'm attempting a [question](https://software.codidact.com/uploads/wxoGToBH6tVpJFBLwBv7P566) 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 `story.title`, `story.author` & `story.subject` (I'm not sure if I'm doing it right too). Can anyone help me out? (Also my title, author and book should not exceed 49 characters)
  • I'm attempting a [question](https://software.codidact.com/uploads/wxoGToBH6tVpJFBLwBv7P566) 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 `story.title`, `story.author` & `story.subject` (I'm not sure if I'm doing it right too). Can anyone help me out? (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;
  • }
#12: Post edited by user avatar dumplings‭ · 2022-06-26T14:22:16Z (almost 2 years ago)
  • I'm attempting a [question](https://software.codidact.com/uploads/wxoGToBH6tVpJFBLwBv7P566) 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? (Also my title, author and book should not exceed 49 characters)
  • I'm attempting a [question](https://software.codidact.com/uploads/wxoGToBH6tVpJFBLwBv7P566) 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 `story.title`, `story.author` & `story.subject` (I'm not sure if I'm doing it right too). Can anyone help me out? (Also my title, author and book should not exceed 49 characters)
#11: Post edited by user avatar dumplings‭ · 2022-06-26T14:21:34Z (almost 2 years ago)
  • I'm attempting a [question](https://software.codidact.com/uploads/wxoGToBH6tVpJFBLwBv7P566) 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? (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){
  • I'm attempting a [question](https://software.codidact.com/uploads/wxoGToBH6tVpJFBLwBv7P566) 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? (Also my title, author and book should not exceed 49 characters)
#10: Post edited by user avatar bta‭ · 2022-01-12T17:09:38Z (about 2 years ago)
Fix formatting
Regarding the implementation of data structures.
  • ![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){
  • I'm attempting a [question](https://software.codidact.com/uploads/wxoGToBH6tVpJFBLwBv7P566) 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? (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){
#9: Post edited by user avatar dumplings‭ · 2021-12-10T16:29:33Z (over 2 years ago)
  • ![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;
  • }
  • ![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){
#8: Post edited by user avatar Canina‭ · 2021-12-10T16:29:04Z (over 2 years ago)
revert to content from revision 4
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;
  • }
#7: Post edited by user avatar dumplings‭ · 2021-12-08T15:09:32Z (over 2 years ago)
  • 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 = "";
  • 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 = "";
#6: Post edited by user avatar dumplings‭ · 2021-12-08T15:09:12Z (over 2 years ago)
  • Hi, I'm attempting a question to do with data structures, file streams & linked lists.
  • //nvm I solved it
  • struct book *aPtr;
  • aBook.title = ""; //how should I write in the double quotes?
  • aBook.author = "";
  • aBook.subject = "";
  • 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 = "";
#5: Post edited by user avatar dumplings‭ · 2021-12-08T15:08:53Z (over 2 years ago)
  • ![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;
  • }
  • Hi, I'm attempting a question to do with data structures, file streams & linked lists.
  • //nvm I solved it
  • struct book *aPtr;
  • aBook.title = ""; //how should I write in the double quotes?
  • aBook.author = "";
  • aBook.subject = "";
#4: Post edited by user avatar dumplings‭ · 2021-12-07T18:11:31Z (over 2 years ago)
  • ![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 & a.Book 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;
  • }
  • ![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;
  • }
#3: Post edited by user avatar dumplings‭ · 2021-12-07T18:10:58Z (over 2 years ago)
  • ![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 & a.Book 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);
  • //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;
  • }
  • ![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 & a.Book 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;
  • }
#2: Post edited by user avatar dumplings‭ · 2021-12-07T18:10:23Z (over 2 years ago)
  • ![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 & a.Book 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, how should I do this?)
  • ```
  • #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);
  • //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;
  • }
  • ![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 & a.Book 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);
  • //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;
  • }
#1: Initial revision by user avatar dumplings‭ · 2021-12-07T18:09:56Z (over 2 years ago)
Regarding the implementation of data structures.
![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 & a.Book 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, how should I do this?)

```
#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);
//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;
}