473,396 Members | 1,996 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Incompatible type conversion

62
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:
Expand|Select|Wrap|Line Numbers
  1.  
  2. void __fastcall TForm1::EnterProductFromFileClick(TObject *Sender)
  3. {
  4.         char ProductName[256]="";
  5.         int ProductID;
  6.         float Weight;
  7.         char WeightCategory[256]="";
  8.         float PriceWithoutVAT;
  9.         float PriceWithVAT;
  10.         char ExpiryDate[256]="";
  11.         int AmountInStock;
  12.         int ReorderLimit;
  13.         char ProductCategory[256]="";
  14.         char InputDate[256]="";
  15.         char DueDate[256]="";
  16.         char Manufacturer[256]="";
  17.         char ManufacturerAddress[256]="";
  18.         char OriginCountry[256]="";
  19.  
  20.         myProductList.getFoodProduct(i)->
  21. ReadDataFromFile(ProductName, ProductID, Weight, WeightCategory,
  22.                                    PriceWithoutVAT, PriceWithVAT, ExpiryDate,
  23.                          AmountInStock, ReorderLimit, ProductCategory,
  24. InputDate, DueDate, Manufacturer, ManufacturerAddress,OriginCountry); 
  25.                     //error in the last line
  26.  
The function itself in class Food:
Expand|Select|Wrap|Line Numbers
  1. void Food :: ReadDataFromFile(char *ProductName,int &ProductID, 
  2.                                   float &Weight, char *WeightCategory,
  3.                                    float &PriceWithoutVAT, float &PriceWithVAT, 
  4.                                   char *ExpiryDate, int &AmountInStock,
  5.                                   int &ReorderLimit, char *ProductCategory,
  6.                                    char *InputDate, char *DueDate,char *Manufacturer,
  7.                                    char *ManufacturerAddress, char *OriginCountry)
  8. {
  9.         ifstream inputfile;
  10.         inputfile.open("input.txt");
  11.  
  12.          char check[256]="";
  13.  
  14.              while(inputfile>>check)
  15.               {
  16.                      inputfile>>ProductID;
  17.                      inputfile>>ProductName;
  18.                      inputfile>>Weight;
  19.                      inputfile>>WeightCategory;
  20.                      inputfile>>ExpiryDate;
  21.                      inputfile>>PriceWithoutVAT;
  22.  
  23.                      PriceWithVAT = CalculateVATPrice(PriceWithoutVAT);
  24.  
  25.                      inputfile>>AmountInStock;
  26.                      inputfile>>ReorderLimit;
  27.                      inputfile>>ProductCategory;
  28.                      inputfile>>InputDate;
  29.                      inputfile>>DueDate;
  30.                      inputfile>>Manufacturer;
  31.                      inputfile>>ManufacturerAddress;
  32.                      inputfile>>OriginCountry;
  33.  
  34.                 };
  35.         inputfile.close();
  36.  
  37. }
  38.  
  39.  
What is wrong here???
Dec 9 '07 #1
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.
Dec 9 '07 #2
jewel87
62
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??
Dec 10 '07 #3
weaknessforcats
9,208 Expert Mod 8TB
why does it say Incompatible type conversion??
The error should say what argument is causing the problem. Maybe you could post the error.
Dec 10 '07 #4
jewel87
62
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
Dec 10 '07 #5
weaknessforcats
9,208 Expert Mod 8TB
Then I have no idea. I can't even see the line number where the error was to have occurred.
Dec 11 '07 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

15
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':...
1
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...
0
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...
6
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...
16
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;
8
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...
13
by: william | last post by:
code segment: long int * size; char entry; ............. size=&entry; ************************************* Gcc reported 'assignment of incompatible pointer type'.
1
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; };
1
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...
0
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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
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...
0
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...
0
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...
0
Oralloy
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,...
0
jinu1996
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...
0
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...
0
tracyyun
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...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.