convert cpp to c, due to I can't connect to header
#include "prob1.h"
using namespace std;
struct ProductData
{
int ID;
char Name[50];
float Price;
int Quantity;
};
struct CustomerData
{
int ID;
char name[50],Address[100],Email[40];
};
struct SalesData
{
long ID,ProductID;
long salseamount;
char name[50],Address[100];
char Email[40];
};
int main()
{
ProductData p;
p.ID=1;
p.Price=12,p.Quantity=12;
char x[50]={'R','A','V','I'};
for(int i=0;i<4;i++)
{
p.Name[i]=x[i];
}
cout<<p.ID<<" "<<p.Name<<" "<<p.Price<<" "<<p.Quantity<<"\n";
CustomerData c;
c.ID=2,c.Email="122";
char y[50]={'A','V','I'};
for(int i=0;i<3;i++)
{
c.name[i]=y[i];
}
char v[50]={'1',' ','s','t','r','e','e','t'};
for(int i=0;i<8;i++)
{
c.Address[i]=v[i];
}
cout<<c.ID<<" "<<c.Email<<" "<<c.name<<" "<<c.Address<<"\n";
SalesData s;
s.ID=3,s.ProductID=12,s.salseamount=1234;
for(int i=0;i<3;i++)
{
s.name[i]=c.name[i];
}
for(int i=0;i<8;i++)
{
s.Address[i]=c.Address[i];
}
cout<<s.ID<<" "<<s.ProductID<<" "<<s.salseamount<<" "<<s.name<<" "<<s.Address;
}
What I have tried:
this is the header
#include<stdio.h>
#include<string.h>
struct ProductData
{
int ID;
char Name[50];
float Price;
int Quantity;
};
struct CustomerData
{
int ID;
char name[50],Address[100],Email[40];
};
struct SalesData
{
long ID,ProductID;
long salesamount;
char name[50],Address[100];
char Email[40];
};