注册 登录
编程论坛 VC++/MFC

conio.h该头文件主要包含什么?streat( , )为什么用不了?

laznrbfe 发布于 2011-05-29 08:45, 529 次点击
/*VC++ 6.0*/
#include<iostream.h>
#include<conio.h>/////////////该头文件主要包含什么?////////////////
#include<string.h>
template <class T>
T Sum(T* array,int size=0)
{
    T total=0;
    for(int i;i<size;i++)
        total+=arry[i];
    return total;
}
template <class T1,class T2>
T2 Sum(T1 *array1,T2 *array2,int size=0)
{
    static T2 total;
    for(int i;i<size;i++)
        total+=arry[i]+arry2[i];
    return total;
}
char * Sum(char *s1,char *s2)
{
    return streat(s1,s2);///////////error C2065: 'streat' : undeclared identifier/////////////
}
int Intarr[]={1,2,3,4,5,6,7,8,9,10};
double Douarr[]={1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10};
void main()
{
    int itotal=Sum(Intarr,10);
    char *p="hello";
    char *p1="world";
    p=Sum(p,p1);
    double dtotal=Sum(Douarr,120);
    double dtotal1=Sum(Intarr,Douarr,10);
    cout<<"The summary of integer array is: "<<itotal<<endl;
    cout<<"The summary of double floating array is: "<<dtotal<<endl;
    cout<<"The summary of two arrays is: "<<dtotal1<<endl;
    cout<<"The summary of two strings is: "<<p<<endl;
}
2 回复
#2
laznrbfe2011-05-29 08:50
streat( , )应该是strcat
#3
laznrbfe2011-05-29 08:57
#include<iostream.h>
#include<conio.h>//该头文件主要包含什么?
#include<string.h>
template <class T>
T Sum(T* array,int size=0)
{
    T total=0;
    for(int i;i<size;i++)
        total+=array[i];
    return total;
}
template <class T1,class T2>
T2 Sum(T1 *array1,T2 *array2,int size=0)
{
    static T2 total;
    for(int i;i<size;i++)
        total+=array1[i]+array2[i];
    return total;
}
char * Sum(char *s1,char *s2)
{
    return strcat(s1,s2);
}
int Intarr[]={1,2,3,4,5,6,7,8,9,10};
double Douarr[]={1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10};
void main()
{
    int itotal=Sum(Intarr,10);
    char *p="hello";
    char *p1="world";
    p=Sum(p,p1);
    double dtotal=Sum(Douarr,20);
    double dtotal1=Sum(Intarr,Douarr,10);
    cout<<"The summary of integer array is: "<<itotal<<endl;
    cout<<"The summary of double floating array is: "<<dtotal<<endl;
    cout<<"The summary of two arrays is: "<<dtotal1<<endl;
    cout<<"The summary of two strings is: "<<p<<endl;
}

为什么执行不了?

1