returning a structure as function return type

I am having problems with my function definition of a function that should return a structure value.
this is the error I get compute.cpp(9): error C2146: syntax error : missing ';' before identifier 's_advertisebus'

the error is on the line where I start my function definition typing my function type as a structure. A long time ago in c the keyword struct is used with the structure type like struct s_advertisebus s_readadbus(). I tried it both ways but I got errors would appreciate your help.

// struct.h
#ifndef STRUCT_H
#define STRUCT_H

struct s_advertisebus
int nnumberofads;
float fpercentused;
double dhowmuchearned;



#include "struct.h"

struct s_advertisebus s_readadbus();
void s_writeadbus(s_advertisebus s_adbus)


s_advertisebus s_readadbus()
using namespace std
s_advertisebus s_input;

cout<< "enter number of ads shown to readers"<<endl;
cin>> s_input.nnumberofads;
cout<< "enter percentage of ads seen"<<endl;
cin>> s_input.fpercentused;
cout<< "enter how much on average earned"<<endl;
cin>> s_input.dhowmuchearned;

return s_input;

void s_writeadbus(s_advertisebus s_adbus)
using namespace std

cout<<"number of ads shown "<< s_adbus.nnumberofads<<endl;
cout<<"percentage of ads seen "<< s_adbus.fpercentused<<endl;
cout<<"how much earned on average "<< s_adbus.dhowmuchearned<<endl;
cout<< "how much made for day "<< s_adbus.nnumberofads*s_adbus.fpercentused*s_adbus.dhowmuchearned<<endl;
// advertisementstruct.cpp : Defines the entry point for the console application.
#include <iostream>
#include "stdafx.h"
#include "struct.h"
#include "prototype.h"

int main()
using namespace std
s_advertisebus s_adbus;

s_adbus = s_readadbus();

cin.ignore( 255,'\n');
return 0;

Firstly, when posting code, please enclose it in code tags to make it more readable.

Secondly, why are you creating an instance of your structure called s_tempstruc? You don't seem to be using it anywhere.

Thirdly, your naming convention is confusing. I had assumed that "s_" indicated that a structure type or object, but you're using it in the names of your functions, too.

Fourthly, you're missing a semicolon at the end of your prototype s_writeadbus. This is probably causing your compiler error.
closed account (zb0S216C)
Each "using namespace std" is missing a semi-colon.

Topic archived. No new replies allowed.