前言
写了一个函数,总共两个函数,一个主函数,一个自己写的函数
g++编译后,运行发现段错误
,搜了下没搜到什么有用的,就自己修改了一下代码,再次编译执行,好了
先看看出问题的代码
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<string>
#include<cstring>
#include<istream>
#include<fstream>
#include<iostream>
#include<sys/socket.h>
#include<time.h>
using namespace std;
int strcmp(const char *str1, const char *str2)
{
for(int x=0; x< strlen(str1); x++)
{
cout << "test\t";
}
return 0;
}
int main(int argc, char *argv[])
{
const char *text[]={"I love you~"};
cout << *text << endl;
return 0;
}
有看出什么来吗?
问题就出在我自己写的那个函数上,因为只是写了一半没写完,想着毕竟又不使用它,于是就保留着直接编译了,所以出错了。
把它注释掉就OK了