Hello everyone,
I'm working on a function reading data from file.
I am getting an error: E2110 Incompatible type conversion
Here is what i have:
function in the form: -
-
void __fastcall TForm1::EnterProductFromFileClick(TObject *Sender)
-
{
-
char ProductName[256]="";
-
int ProductID;
-
float Weight;
-
char WeightCategory[256]="";
-
float PriceWithoutVAT;
-
float PriceWithVAT;
-
char ExpiryDate[256]="";
-
int AmountInStock;
-
int ReorderLimit;
-
char ProductCategory[256]="";
-
char InputDate[256]="";
-
char DueDate[256]="";
-
char Manufacturer[256]="";
-
char ManufacturerAddress[256]="";
-
char OriginCountry[256]="";
-
-
myProductList.getFoodProduct(i)->
-
ReadDataFromFile(ProductName, ProductID, Weight, WeightCategory,
-
PriceWithoutVAT, PriceWithVAT, ExpiryDate,
-
AmountInStock, ReorderLimit, ProductCategory,
-
InputDate, DueDate, Manufacturer, ManufacturerAddress,OriginCountry);
-
//error in the last line
-
The function itself in class Food: -
void Food :: ReadDataFromFile(char *ProductName,int &ProductID,
-
float &Weight, char *WeightCategory,
-
float &PriceWithoutVAT, float &PriceWithVAT,
-
char *ExpiryDate, int &AmountInStock,
-
int &ReorderLimit, char *ProductCategory,
-
char *InputDate, char *DueDate,char *Manufacturer,
-
char *ManufacturerAddress, char *OriginCountry)
-
{
-
ifstream inputfile;
-
inputfile.open("input.txt");
-
-
char check[256]="";
-
-
while(inputfile>>check)
-
{
-
inputfile>>ProductID;
-
inputfile>>ProductName;
-
inputfile>>Weight;
-
inputfile>>WeightCategory;
-
inputfile>>ExpiryDate;
-
inputfile>>PriceWithoutVAT;
-
-
PriceWithVAT = CalculateVATPrice(PriceWithoutVAT);
-
-
inputfile>>AmountInStock;
-
inputfile>>ReorderLimit;
-
inputfile>>ProductCategory;
-
inputfile>>InputDate;
-
inputfile>>DueDate;
-
inputfile>>Manufacturer;
-
inputfile>>ManufacturerAddress;
-
inputfile>>OriginCountry;
-
-
};
-
inputfile.close();
-
-
}
-
-
What is wrong here???
5 7786
I would suggest using a structure or a class to store information about the product, rather than reams of individual variables. Simply pass an instance of this struct or class by non-const reference to the function which reads the data from the file, or better yet, make that function a member function of the new class.
I would suggest using a structure or a class to store information about the product, rather than reams of individual variables. Simply pass an instance of this struct or class by non-const reference to the function which reads the data from the file, or better yet, make that function a member function of the new class.
I am using classes, and this function is a member of class. I have some problem with function call, why does it say Incompatible type conversion??
why does it say Incompatible type conversion??
The error should say what argument is causing the problem. Maybe you could post the error.
The error should say what argument is causing the problem. Maybe you could post the error.
There is the problem, it is not saying anything about any types at all, just as it is here:
E2110: Incompatible type conversion
Then I have no idea. I can't even see the line number where the error was to have occurred.
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Chris Readle |
last post by:
Hi all,
Somewhat new to C and I'm getting the following error from my latest code.
Here's the warning I'm getting:
chris_readle_project3_assignment3.c: In function `main':...
|
by: Josh Wilson |
last post by:
Hey gang,
So I have my stdin which is user defined file, and am wanting to write
it to a temporary file (seems odd I know, but there is a sincere
reason), and then use that file as the stdin for...
|
by: Brian Takita |
last post by:
Hello,
I'm getting the following error at the end of this message when trying
to run the ReportManager and the ReportServer:
Assembly system.data.dll security permission grant set is...
|
by: PraZ |
last post by:
Hi all.
Here is a simple code, which when compiled with gcc results in the
warning "incompatible pointer type" for arg 1, as expected. But this is
just what I want to do, because it makes it...
|
by: v4vijayakumar |
last post by:
Whats wrong with the code in line no. 7?!
#cat test3.c
#include <stdio.h>
int main(int argc, char *argv)
{
int ia1 = {0, 1, 2};
int ia2;
ia2 = ia1;
|
by: fei.liu |
last post by:
I have the following source code. It seems wierd to me why gca's value
cannot be reassigned. It's afterall a pointer and has a pointer value.
I am aware that the standard says it's not allowed. But...
|
by: william |
last post by:
code segment:
long int * size;
char entry;
.............
size=&entry;
*************************************
Gcc reported 'assignment of incompatible pointer type'.
|
by: pyo2004 |
last post by:
Here's the definition of work_struct
struct work_struct {
unsigned long pending;
struct list_head entry;
void (*func)(void *);
void *data;
void *wq_data;
struct timer_list timer;
};
|
by: sanusultan |
last post by:
Hello everyone,
I'm working on my project I have written the code for my project in c.
I am getting an error: E2110 Incompatible type conversion
Here is what i have:
my
code:
code...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
| |