程序在Dev-C++5.5.3版本运行结构体的使用给结构体赋值,打印出结构体中学生姓名,分数,平均分#include #include #include #include #include //不用.h的话可能下面的strcpy用不了 #include using namespace std; i....
分类:
编程语言 时间:
2015-06-09 11:34:45
阅读次数:
153
周末赶数据结构的作业,整理的一些关于C语言中字符数组的困惑与解答。1.赋值C语言中,给字符数组char s[]赋值使用strcpy (在string.h头文件中)#include #include int main(){ char test[3][4]; strcpy(test[0], "abc")...
分类:
编程语言 时间:
2015-06-08 11:13:59
阅读次数:
200
int strlen(char* s){ int ret = 0; while(*s != 0) { ret++; *s++; } return ret;}char* strcpy(char* dest, char* src){ cha...
分类:
其他好文 时间:
2015-06-07 21:28:49
阅读次数:
114
strncpy()函数原型:extern char *strncpy(char *dest, char *src, int n); 使用方法:#include 功能:把src所指由NULL结束的字符串的前n个字节拷贝到dest所指的数组中。 说明:假设src的前n个字节不含NULL字符,则结果不会....
分类:
其他好文 时间:
2015-06-06 20:43:58
阅读次数:
119
#include
#include
using namespace std;
class String
{
public:
String(const char *str = " ")
{
m_data = new char[strlen(str) + 1];
strcpy(m_data, str);
count++;
}
String(const String &s)
...
分类:
编程语言 时间:
2015-06-05 22:49:07
阅读次数:
162
// 深拷贝,异常安全的深赋值
#include
#include
using namespace std;
class String
{
public:
String(const char *str = " ")
{
m_data = new char[strlen(str) + 1];
strcpy(m_data, str);
}
String(const String...
分类:
编程语言 时间:
2015-06-05 17:32:26
阅读次数:
144
大家一般觉得名不见经传strcpy函数实现不是非常难,流行的strcpy函数写法是:char *my_strcpy(char *dst,const char *src){ assert(dst != NULL); assert(src != NULL); char *ret = dst; while...
分类:
其他好文 时间:
2015-06-04 19:00:57
阅读次数:
127
记录一个简单的栈溢出的实例,具体的分析以后加进去。 程序源代码buffer.c: #include #include void fun1(char *input) { char buffer[10]; strcpy(buffer,input); printf("Call fun1,buffer=%s...
分类:
其他好文 时间:
2015-06-03 11:37:55
阅读次数:
93
#include
#include
using namespace std;
class Person
{
public:
Person(char* c)
{
strcpy_s(name,c);//本来是strcpy的,但是vs2005以后的版本都要改写成strcpy_s
/*mkdir改写为 _mkdir fopen”改写为 fopen_s
stricmp改写为 str...
分类:
其他好文 时间:
2015-06-02 22:00:31
阅读次数:
164
strcpy
原型:extern char *strcpy(char *dest,char *src);
用法:#include
功能:把src所指由NULL结束的字符串复制到dest所指的数组中。
说明:src和dest所指内存区域不可以重叠且dest必须有足够的空间来容纳src的字符串。
返回指向dest的指针。
例:char a[100],b[50];strcp...
分类:
其他好文 时间:
2015-06-02 09:21:58
阅读次数:
118