Problem with an array in a structure

Hi fellows i am making this program for a class of mine and i am trying to capture a bar code of 8 digits i am not sure wether i should should define the variable with char or with int anyhow my problem is that it would always tell me that my condition is wrong here is the part of my code that is not working and also the structure.

#include <iostream>
#include <conio.h>
#include <string>
#include <stdio.h>

using namespace std;

struct bazzinga{
string name;
string console;
float price ;
string tipo;
char bar[7];
} videogame[9];

void main ()
system ("cls");
cout<<"\t\t Add bar code"<<endl<<endl;
cout<<endl<<"Itroduce bar code of "<<videogame[i].name<<endl;
cout<<"\tBar could should only contain 8 digits"<<endl;
if (videogame[i].bar<=00000000 || videogame[i].price>99999999)
system ("cls");
cout<<"ERROR\n Bar code should contain 8 digits, try again"<<endl;
system ("PAUSE");

}while(videogame[i].bar<=00000000 || videogame[i].bar>99999999);

i know i must be wrong with the if statement is just that i already tried so many ways like searching for null or \0 in the last place of the structure variable that i tought this could be the easiest way any hints or help will be very welcome.
Last edited on
I don't think you can give a struct an alias name like that.

If you want a global variable i beleive it needs to be:

bazzinga videogame[9];

after the struct definition.
Assuming you can give a struct alias name like that
How do i make my code work?? it should be able to accept 8 digits no more no less not char nor anything should i use scanf ?? help please
Topic archived. No new replies allowed.