Need Help for a simple program!!!

Hello. I am a beginner in c++, and I definitely need some help for this program!!
I just cannot find the errors in it... Please help me!

#include <stdio.h>

struct account {
int number;
char s_adress[40];
char city_state[40];
double zip_code;
double balances;
double limit;
char name[40];

void getinfo(struct account *);
void showinfo(const struct account *);

int main(void)
struct account customer;

printf("Hello. This program will store your account information.\n");


printf("Thank you.");

return 0;

void getinfo (struct account * pst)
printf("Please enter your account number.\n");
gets(pst -> number);
printf("Please enter your street adress.\n");
gets(pst -> s_adress);
printf("Please enter the city and the state you live in.\n");
gets(pst -> city_state);
printf("Please enter your zip code.\n");
gets(pst -> zip_code);
printf("Please enter your balances.\n");
gets(pst -> balances);
printf("Please enter your credit limit.\n");
gets(pst -> limit);
printf("Please enter your name.\n");
gets(pst -> name);

void showinfo (const struct account * pst)
printf("The information you entered in:\n\n");
printf("Account number: %d\n", pst -> number);
printf("Account owner street address: %s\n", pst -> s_adress);
printf("Account owner city/state: %s\n", pst -> city_state);
printf("Account owner zip code: %f\n", pst -> zip_code);
printf("Account balances: %f\n", pst -> balances);
printf("Account credit limit: %f\n", pst -> limit);
printf("Account name: %s\n", pst -> name);
What errors are you getting?
I see no compilation errors.

One problem I do see is that you can't do a gets on an integer or a double.
gets(pst -> number);
gets(pst -> zip_code);
gets(pst -> balances);
gets(pst -> limit);

PLEASE USE CODE TAGS (the <> formatting button) when posting code.
It makes it easier to read your code and it also makes it easier to respond to your post.

BTW, you say you're learning C++, but I see no C++ code.
Last edited on
BTW, you say you're learning C++, but I see no C++ code.

I agree, the posted code is a typical C program.
Topic archived. No new replies allowed.