2

私はこの小さなプログラムをC++で実行していますが、コードブロックに次のエラーが表示されます:エラー:

'atod'はこのスコープでは宣言されていません

このコードには何が欠けていますか?ありがとうございました。

#include <stdio.h>
#include <stdlib.h>
#include <conio.h>
#include <string.h>
#include <fstream>
#include <math.h>
#include <iostream>

using namespace std;


class birth{
};


int main (void){

    int pass=1;
    string date, boy, aux1, aux2, aux4;
    double f;

    while(pass=! 0){
        cout<<"Enter the name of the birthday boy"<<endl;
        cin>>boy;
        cout<<"Enter the date of birth" <<endl;
        cin>>date;
        aux1= aux1.substr(5,10);
        f= atod(aux1);
        f=2012-f;
        cout<< "The birthday boy "<<boy<<"who born"<<date<<"now have"<<f<<"years"<<endl


        cout<<"Do you want to enter more birthdays?"<<endl;
        cout<<"1.- YES"<<endl;
        cout<<"2.- NO"<<endl;
        cin>>pass;
    }

    system ("pause");
    return 0;
};

編集:問題はこの行にあります:

 f= atod(aux1);
4

2 に答える 2

3

関数を使用しatofます。にありstdlib.hます。const char*ではなく、に渡す必要がありstd::stringます。

f = atof(aux1.c_str());
于 2012-09-24T02:14:38.463 に答える
1


atod use_atold()やのような機能はありませんatof()、これらはmath.h&にありますstdlib.h

于 2012-09-24T02:18:50.113 に答える