Here's a little program i wrote, i'm trying to pass my structure book to function input. The code works fine on Code::Blocks but VS12 is giving an error on compliation " error C4700: uninitialized local variable 's' used ". What i'm doing wrong?
#include <string.h>
#include <iostream>
using namespace std;
struct book{
char title[20];
char author[20];
int price;
};
book input(struct book);
void display(struct book);
book input(book details)
{
cout << "Book Title : ";
gets_s(details.title);
cout << "\nBook Author : ";
gets_s(details.author);
cout << "\nBook : Price : ";
cin >> details.price;
return details;
}
void display(book details)
{
cout<<"\n\nBook Details\n\n";
cout << "\nBook Title : ";
puts(details.title);
cout << "\nBook Author : ";
puts(details.author);
cout << "\nBook : Price : ";
cout<<details.price<<endl;
}
int main()
{
book s;// Here's "s" initialized struct variable
s = input(s);
display(s);
system("PAUSE");
return 0;
}