[prog] C++ Problem
anti tanvir
anti_tanvir at yahoo.co.uk
Sun Apr 6 07:53:10 EST 2003
Hi I'm writing this little C++ program but the problem
is that car's name (Audi) is not showing up..
This is the main cpp program.
#include<iostream>
#include "vehicle.h"
using namespace std;
int main(int argc,char *argv[])
{
Vehicle a;
InitialiseVehicle(&a,"Audi");
cout<<"Original Statistics : "<<endl;
cout<<"======================"<<endl;
PrintVehicle(a);
return 0;
}
This is the header file
#include <iostream>
using namespace std;
struct Vehicle
{
char vehicle_name[20];
float km;
float litre;
float fuel_cost;
};
void InitialiseVehicle (Vehicle *a, char name[20])
{
a->vehicle_name, name;
a->km=0;
a->litre=0;
a->fuel_cost=0;
}
void PrintVehicle (Vehicle a)
{
cout << "Vehicle:" << a.vehicle_name <<endl;
cout << a.km << "km travelled requiring " <<
a.litre << " litres of fuel at a cost of $"
<<a.fuel_cost<<endl;
}
When I run this program everything goes fine but the
output for vehicle is "Vehicle:some nonsense
characters"
Any help would be greatly appreciated.
__________________________________________________
Yahoo! Plus
For a better Internet experience
http://www.yahoo.co.uk/btoffer
More information about the Programming
mailing list