#include<stdio.h>
#include<conio.h>
struct books {
int id;
char title;
char author;
int year;
long isbn;
};
int main() {
struct books b;
clrscr();
printf("\n Enter BOOK ID: ");
scanf("%d",&b.id);
printf("\n Enter BOOK TITLE: ");
scanf("%s",&b.title);
printf("\n Name of AUTHOR: ");
scanf("%s",&b.author);
printf("\n Enter YEAR: ");
scanf("%d",&b.year);
printf("\n Enter ISBN: ");
scanf("%d",&b.isbn);
printf("\n BOOK ID: %d \n ",b.id);
printf("\n TITLE: %s \n ",b.title);
printf("\n AUTHOR: %s \n ",b.author);
printf("\n YEAR: %d \n ",b.year);
printf("\n ISBN: %d \n ",b.isbn);
getch();
return 0;
}
Now, when i execute this I get to enter the values for id,year and isbn but for title,and author when i enter the names it shows 'abnormal termination' can someone please tell me what did i do wrong?
you are entering title which is a
std::stringbut you are usingcharwhich can be causing an error. Also you are using%dfor long which is wrong as you should be using%ldfor that.Not only that sometimes it is not your code that produces the error but Turbo C++ that causes it. So try to relaunch Turbo C++ and if possible run the same code on another IDE to check if the code is actually wrong.