error: invalid operands to binary / (have ‘float’ and ‘int *’)
-
Quote:
error: invalid operands to binary / (have ‘float’ and ‘int *’)
how to solve this error?
You can't divide by a pointer. You can divide by what it points to, but you cant divide the pointer itself. Take a look at the following. Basically, you need to dereference the pointer, as I've done in #3.
#include <cstdio>
int main()
{
int numerator = 10;
float denominator = 2.7;// 1. Using no pointers float result = numerator / denominator; printf("%d / %f = %f\\n", numerator, denominator, result); // 2. Using pointers incorrectly int \*ptrToNumerator; ptrToNumerator = &numerator; // below line causes the following error: // error: invalid operands of types 'int\*' and 'float' to binary 'operator/'| result = ptrToNumerator / denominator; printf("%f\\n", result); // 3. Using pointers appropriately result = \*ptrToNumerator / denominator; printf("%f\\n", result); return 0;
}
-
You can't divide by a pointer. You can divide by what it points to, but you cant divide the pointer itself. Take a look at the following. Basically, you need to dereference the pointer, as I've done in #3.
#include <cstdio>
int main()
{
int numerator = 10;
float denominator = 2.7;// 1. Using no pointers float result = numerator / denominator; printf("%d / %f = %f\\n", numerator, denominator, result); // 2. Using pointers incorrectly int \*ptrToNumerator; ptrToNumerator = &numerator; // below line causes the following error: // error: invalid operands of types 'int\*' and 'float' to binary 'operator/'| result = ptrToNumerator / denominator; printf("%f\\n", result); // 3. Using pointers appropriately result = \*ptrToNumerator / denominator; printf("%f\\n", result); return 0;
}
Quote:
for(i=0;i<*SizeOfData;i++)
{
datasample[i]=square(samplesValue1[i]);
squaring1=(datasample[i]*datasample[i]);
sum +=squaring1;
}
summation_input=(float)sum/ *SizeOfData;
printf("\n%f",summation_input);fclose(fp);
wen i change summation_input=(float)sum/SizeOfData; to summation_input=(float)sum/ *SizeOfData some unknown error is generating given below
Quote:
dithermain.c:(.text+0x430): undefined reference to `square' collect2: ld returned 1 exit status
-
Quote:
for(i=0;i<*SizeOfData;i++)
{
datasample[i]=square(samplesValue1[i]);
squaring1=(datasample[i]*datasample[i]);
sum +=squaring1;
}
summation_input=(float)sum/ *SizeOfData;
printf("\n%f",summation_input);fclose(fp);
wen i change summation_input=(float)sum/SizeOfData; to summation_input=(float)sum/ *SizeOfData some unknown error is generating given below
Quote:
dithermain.c:(.text+0x430): undefined reference to `square' collect2: ld returned 1 exit status
That error is telling you that the linker can't find the function body for your function
square
. If it's in another c/cpp file, you have to compile and link it too. Otherwise, you can just place thesquare
function in the same c/cpp file, but make sure it appears before it's first used. (otherwise you'll get a compiler error that says the symbol is unrecognized) -
That error is telling you that the linker can't find the function body for your function
square
. If it's in another c/cpp file, you have to compile and link it too. Otherwise, you can just place thesquare
function in the same c/cpp file, but make sure it appears before it's first used. (otherwise you'll get a compiler error that says the symbol is unrecognized) -
in function after writing return(); is it possible to continue process will it be effective ?
maibam debina wrote:
in function after writing return(); is it possible to continue process...
Not in that same function.
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"You can easily judge the character of a man by how he treats those who can do nothing for him." - James D. Miles