Error: Declaration Syntax error on function input
Note: using turbo c++ 4.5 compiler

#include "iostream.h"
#include "conio.h"
#include "stdlib.h"
#include "cstring.h"
#include "fstream.h"
#include "time.h"
#include "stdio.h"
time_t now=time(0);char*dt=ctime(&now);

int ch,dn=0;
struct BuyerInfo
 char id[5];
 string fn;
 string mn;
 string ln;
 string ad;
struct grocery
char barcode[5];
string prodname;
string category;
float price;
} ;

void inputs()
 cout<< "\n================================================================================";
 cout<< "\t\t\n\t\t  Please fill in the following required information\n";
 cout<< "\n================================================================================";
char ans='y';
    while (ans=='y'||ans=='Y')
        cout<< "\nBuyer's ID:B";
            FILE * pFile;
            pFile=fopen (info[dn].id,"rb");
                    cout<<" ID NUMBER IS IN USED"<<endl;
                    cout<<" DO YOU WANT TO ENTER ANOTHER?(Y/N) ";
                    if( ans=='n'||ans=='N')_exit(0);
                FILE * mFile;
                mFile=fopen (info[dn].id,"w");
                fclose (mFile);ans='?';
                    cout<< "Enter First Name:";
                    cout<< "Enter Middle Name:";
                    cout<< "Enter Last Name:";
                    cout<< "Enter Address:";
                    cout<<"Date: "<<dt;

void mainscreen()
    cout<< "\n================================================================================";
    cout<< "\t\t\t         VONGOLA POINT OF SALE SYSTEM";
    cout<< "\n================================================================================";
    cout<< "\nPlease choose from the following:";
    cout<< "\n[1]Scan Buyer's Items";
    cout<< "\n[2]Additional Items";
    cout<< "\n[3]Cancel Items";
    cout<< "\n[4]Searching for Buyer's Record";
    cout<< "\n[5]Deleting Buyer's Record";
    cout<< "\n[6]Show all Products available in the Grocery Store";
    cout<< "\n[7]Show Products based on Product Category";
    cout<< "\n[8]Exit";
    cout<< "\n================================================================================";
    cout<< "\nOption:";

int main()
grocery data[50];
ifstream in;"grocery.txt");
for(int i = 0;i<50; i++)
in >>data[i].barcode >> data[i].prodname >> data[i].category >> data[i].price;
return 0;

    case '1':break;
    case '2':break;
    case '3':break;
    case '4':break;
    case '5':break;
    case '6':break;
    case '7':break;
    case '8':break;

Recommended Answers

All 5 Replies

It would be much easier if you posted the line on which the syntax error occured, if it is possible anyway.

However, the problem I see is with line 99:

in >>data[i].barcode >> data[i].prodname >> data[i].category >> data[i].price;

The member variables 'prodname' and 'category' of type std::string but you're trying to use the overloaded shift-right operator '>>' with the file stream 'ifstream'. The problem is, there is no overloaded version that handles std::string variables.

You can check the list of available functions and parameters with '>>' here:>>/ (just copy and paste)

There is no such thing as istream& operator>> (istream& is, std::string& str);

You have to use the std::string compatible versions to extract a std::string from a stream.
istream& getline ( istream& is, string& str, char delim );
istream& getline ( istream& is, string& str );

And on line 103 you have return 0; so whatever code follows never get executed.

it highlighted...line 74

Wow, you can ignore my post.

You can use the operator >> with std::string which is defined under the Strings library

And I forgot to mention on line 41 you have strcat(info[dn].id,".docx"); but member variable 'id' is only 5 characters long. The string ".docx" itself is 5 characters long plus the null character.

Line 74 is an open brace in void mainscreen().

You obviously haven't learned how to format your code yet. Please take a look at this and format your code properly so it can be followed. Many errors can be found in seconds with properly formatted code.

thanks for that! fixed now..

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.