Aşağıdaki kodun çalıştırılmasıyla ilgili bazı sorunlar yaşıyorum. Bunu elde ettim: C2668 hatası: 'pow': aşırı yüklenmiş fonksiyona muğlak çağrı. Argümanları static_cast kullanarak uygun tipte el ile yapmaya çalıştım, ancak bazı işaretçi hataları aldığımı düşünüyorum ?!Aşırıya çalışma işlevi 'pow' için belirsiz çağrı
programı 10.
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <stdlib.h>
#include <conio.h>
#include <string.h>
#include <math.h>
//base 16 to base 10
int convert(char *n){
int result = 0;
for (int i = strlen(n) - 1; i >= 0; i--){
if (n[i] >= 'a')
result += (n[i] - 'a' + 10)* pow(16, strlen(n) - i - 1);
else
if (n[i] >= 'A')
result += (n[i] - 'A' + 10)* pow(16, strlen(n) - i - 1);
else
if (n[i] >= '0')
result += (n[i] - '0')* pow(16, strlen(n) - i - 1);
}
return result;
}
void main(void){
char n[10];
printf("Introduceti numarul: "); scanf("%s", n);
printf("Numarul in baza 10 este: %d", convert(n));
_getch();
}
Bunların hepsi hatalardır dayandırmak tabanından 16 arasında bir sayı dönüştürmek gerekir.
1>------ Build started: Project: pr8, Configuration: Debug Win32 ------
1> pr8.cpp
1> error C2668: 'pow' : ambiguous call to overloaded function
1> could be 'long double pow(long double,int) throw()'
1> or 'long double pow(long double,long double) throw()'
1> or 'float pow(float,int) throw()'
1> or 'float pow(float,float) throw()'
1> or 'double pow(double,int) throw()'
1> or 'double pow(double,double)'
1> while trying to match the argument list '(int, size_t)'
1>'-' : pointer can only be subtracted from another pointer
1> error C2668: 'pow' : ambiguous call to overloaded function
1> could be 'long double pow(long double,int) throw()'
1> or 'long double pow(long double,long double) throw()'
1> or 'float pow(float,int) throw()'
1> or 'float pow(float,float) throw()'
1> or 'double pow(double,int) throw()'
1> or 'double pow(double,double)'
1> while trying to match the argument list '(int, size_t)'
1> error C2668: 'pow' : ambiguous call to overloaded function
1> could be 'long double pow(long double,int) throw()'
1> or 'long double pow(long double,long double) throw()'
1> or 'float pow(float,int) throw()'
1> or 'float pow(float,float) throw()'
1> or 'double pow(double,int) throw()'
1> or 'double pow(double,double)'
1> while trying to match the argument list '(int, size_t)'
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
Bunu nasıl düzeltebilirim? Teşekkür ederim. C++ içinde size_t
döndürme türü
Gerçekten gerekmez 'pow()' Eğer ikisinin bir güç exponentiating konum olarak burada hiç, sen vardiya kullanabilirsiniz. – EJP
Bu, C++ olarak C kodu derlenmiş edilmektedir. Derleyicinin sadece küçük bir ayrışma kimliği bozukluğu var. Bir dil seçin ve ona yapıştırın. –
@Stefan: #include 'satırını #include ' olarak değiştirmeyi deneyin. Bu entegre bağımsız değişkenleri alır POW() '' ve 'C++ 11' aşırı almak olabilir. –
Blastfurnace