0

関数 p1() を p2() として書き直して、p1() を正確に模倣する<iomanip>必要があります。

型の無効なオペランドlong long unsigned intと「未解決の関数型」をバイナリにoperator<<

コードは次のとおりです。

void p1()
{
    printf("Size of different basic C++ data type in number of bytes\n\n") ;
    printf("size of int           = %d \n", sizeof (int) ) ;
    printf("size of long          = %d \n", sizeof (long) ) ;
    printf("size of short         = %d \n", sizeof (short) ) ;
    printf("size of unsigned int  = %d \n", sizeof (unsigned int) ) ;
    printf("size of char          = %d \n", sizeof (char) ) ;
    printf("size of wchar_t       = %d \n", sizeof (wchar_t) ) ;
    printf("size of bool          = %d \n", sizeof (bool) ) ;
    printf("size of float         = %d \n", sizeof (float) ) ;
    printf("size of double        = %d \n", sizeof (double) ) ;
    printf("size of long double   = %d \n", sizeof (long double) ) ;
    printf("size of int ptr       = %d \n", sizeof (int *) ) ;
    printf("size of double ptr    = %d \n", sizeof (double *) ) ;
    printf("size of char ptr      = %d \n", sizeof (char *) ) ;
    printf("====================================\n\n") ;
}

これが私が使用しなければならない p2() です<iomanip>:

void p2()
{
    cout<<"Size of different basic C++ data type in number of bytes\n\n";  
    cout<<setw(10)<<"size of int"<<"= %d" ,sizeof (int)<<endl;
    cout<<setw(10)<<"size of long"<<"= %d" ,sizeof (long)<<endl;
    cout<<setw(10)<<"size of short"<<"= %d", sizeof (short)<<endl ;
    cout<<setw(10)<<"size of unsigned int"<<"= %d", sizeof (unsigned int)<<endl;
    cout<<setw(10)<<"size of char"<<"= %d", sizeof (char)<<endl;
    cout<<setw(10)<<"size of wchar_t"<<"= %d", sizeof (wchar_t)<<endl;
    cout<<setw(10)<<"size of bool"<<"= %d", sizeof (bool)<<endl;
    cout<<setw(10)<<"size of float"<<"= %d", sizeof (float)<<endl;
    cout<<setw(10)<<"size of double"<<"= %d", sizeof (double)<<endl;
    cout<<setw(10)<<"size of long double"<<"= %d", sizeof (long double)<<endl;
    cout<<setw(10)<<"size of int ptr"<<"= %d", sizeof (int *)<<endl;
    cout<<setw(10)<<"size of double ptr"<<"= %d", sizeof (double *)<<endl;
    cout<<setw(10)<<"size of char ptr"<<"= %d", sizeof (char *)<<endl;
    cout<<setfill('=')<<setw(40)<<"="<<endl;
}
4

1 に答える 1