70,037
社区成员
发帖
与我相关
我的任务
分享
char *attackType[][10]={
{"normal"},
{"ip sweep","nmap","portsweep","satan","saint","mscan"},
{"back","land","neptune","pod","smurf","teardrop","apache2","mailbomb","udpstorm","processtable"},// 10
{"perl","rootkit","loadmodule","buf_overflow","httptunned","ps","sqlttack","xterm"}};
#include <stdio.h>
#include <string.h>
int main ()
{
char str[100]="00,0.00,0.45,0.01,normal.";
char *p;
p=strtok(str,",");
while (p!=NULL)
{
if (!strcmp(p,"normal."))
{
printf("%s\n", p);
strcpy(p,"normal");
printf("%s\n",p);
}
p=strtok(NULL,",");
}
return 0;
}
#include <iostream>
#include <string>
#include <regex>
#include <cassert>
using namespace std;
int main()
{
string str = "每一行内容";
tr1::regex rx("normal");
// 使用 regex_search
//assert( regex_search(str.begin(), str.end(), rx) );
if (regex_search(str.begin(), str.end(), rx))
{
cout<<"find it!"<<endl;// ok,说明此行有normal
}
else
{
cout<<"not find!"<<endl;
}
}
//just try !
while (fgets( line, buff_size, input ) != NULL)
{
int temp=0;
result = strtok(line, ","); //read the first attribute
temp++;
while( result != NULL )
{
if (!strcmp(result,"normal"))
{
printf("%s is in the %d line\n",result, temp);
break;
}
result = strtok(NULL, ",");
}
}
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main()
{
FILE *input,*output;
char*result = NULL;
int buff_size=200;
char*line = (char*)malloc(buff_size);
int i;
input = fopen("e:\\kddcup.data_10_percent_corrected","r");
if(input == NULL)
{
printf("\nerror on open e:\\kddcup.data_10_percent_corrected file!");
free(line);
exit(0);
}
if((output=fopen("e:\\b.xls","at+")) == NULL)
{
printf("Cannot open file strike any key exit!");
exit(0);
}
while (fgets( line, buff_size, input ) != NULL)
{
int temp=0;
result = strtok(line, ","); //read the first attribute
for(i=0;i<41;i++){
while( result != NULL )
{
//mapping and scaling the 41 attributs + 1 class respectively
//duration, continuous, [0, 58329]
fputs(result,output);
fputs("\t",output);
break;
} //switch end
result = strtok(NULL, ",");
}
}//while end
fclose(input);
free(line);
return 0;
}
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main()
{
FILE *input,*output;
char*result = NULL;
int buff_size=200;
char*line = (char*)malloc(buff_size);
int i;
input = fopen("e:\\kddcup.data_10_percent_corrected","r");
if(input == NULL)
{
printf("\nerror on open e:\\kddcup.data_10_percent_corrected file!");
free(line);
exit(0);
}
if((output=fopen("e:\\b.xls","at+")) == NULL)
{
printf("Cannot open file strike any key exit!");
exit(0);
}
while (fgets( line, buff_size, input ) != NULL)
{
int temp=0;
result = strtok(line, ","); //read the first attribute
for(i=0;i<41;i++){
while( result != NULL )
{
//mapping and scaling the 41 attributs + 1 class respectively
//duration, continuous, [0, 58329]
fputs(result,output);
fputs("\t",output);
break;
} //switch end
result = strtok(NULL, ",");
}
}//while end
fclose(input);
free(line);
return 0;
}