64,683
社区成员
发帖
与我相关
我的任务
分享
char cp;
string str;
cp='a';
str=str+cp;//这么写没有问题吧??
cout<<str<<endl;
string str;
str=str+"中文";//这里有问题没?
string str="up";
char *cp;
cp=new char[str.size()+1];
strcpy_s(cp,str.c_str());//就将之前的一个帖子里的代码改了strcpy改成了strcpy_s()就报错了
cout<<cp<<endl;
#include "stdafx.h"
#include<string>
#include<iostream>
using namespace std;
int _tmain(int argc, _TCHAR* argv[])
{
char cp;
string str;
cp='a';
str=str+cp;
str=str+"中文";
cout<<str<<endl;
return 0;
}
#include <iostream>
#include <string>
using namespace std;
int main()
{
char cp;
string str;
cp='a';
str=str+cp;
cout<<str<<endl;
return 0;
}
#include <iostream>
#include <string>
using namespace std;
int main()
{
string str;
str=str+"中文";
cout<<str<<endl;
return 0;
}
string str="up";
char *cp;
cp=new char[str.size()+1];
strcpy_s(cp,str.c_str());//就将之前的一个帖子里的代码改了strcpy改成了strcpy_s()就报错了
cout<<cp<<endl;
//函数声明
errno_t strcpy_s(
char *strDestination,
size_t numberOfElements,
const char *strSource
);
// crt_strcpy_s.cpp
// This program uses strcpy_s and strcat_s
// to build a phrase.
//
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
#include <errno.h>
int main( void )
{
char string[80];
// using template versions of strcpy_s and strcat_s:
strcpy_s( string, "Hello world from " );
strcat_s( string, "strcpy_s " );
strcat_s( string, "and " );
// of course we can supply the size explicitly if we want to:
strcat_s( string, _countof(string), "strcat_s!" );
printf( "String = %s\n", string );
}
Error Message
Error spawning 'command line'.
A command, command line, which was formed from input in the Property Pages dialog box, returned an error code but no information will appear in the Output window.
Possible reasons for this error:
Your project depends on ATL Server. Beginning with Visual Studio 2008, ATL Server is no longer included as part of Visual Studio, but has been released as a shared-source project at CodePlex. To download the ATL Server source code and tools, go to http://go.microsoft.com/fwlink/ ? LinkID=81979.
Low system resources. Close some applications to resolve this.
Insufficient security privileges. Verify that you have sufficient security privileges.
The executable paths specified in VC++ Directories do not include the path for the tool that you are attempting to run.
For makefile projects, you are missing a command to run on either Build Command Line or Rebuild Command Line.
#include <string>
#include <iostream>
using namespace std;
int main()
{
char cp;
string str;
cp='a';
str=str+cp;//这么写没有问题吧??
cout<<str<<endl;
system("pause");
}
#include <string>
#include <iostream>
using namespace std;
int main()
{
string str;
str=str+"中文";//这里有问题没?
system("pause");
}
#include <string>
#include <iostream>
using namespace std;
int main()
{
string str="up";
char *cp; cp=new char[str.size()+1];
strcpy_s(cp,sizeof(cp),str.c_str());//非strcpy_s(cp,str.c_str()),注意参数少一个
cout<<cp<<endl;
system("pause");
}
#include "stdafx.h"
#include<string>
#include<iostream>
using namespace std;
int _tmain(int argc, _TCHAR* argv[])
{
string str="up";
char *cp;
cp=new char[str.size()+1];
//cout<<str.size()<<" "<<str.c_str()<<endl;
strcpy_s(cp,str.size()+1,str.c_str());//第一种形式
cout<<cp<<endl;
char cp2[3];
strcpy_s(cp2,str.c_str());//第二种形式
cout<<cp2<<endl;
return 0;
}
string str="up";
//char *cp=new char[str.size()+1];
char cp[3];
strcpy_s(cp,str.c_str());
cout<<cp<<endl;
template <size_t size>
errno_t wcscpy_s(
wchar_t (&strDestination)[size],
const wchar_t *strSource
); // C++ only
errno_t strcpy_s(
char *strDestination,
size_t numberOfElements,
const char *strSource
);