Есть файл с разной информацией, например:
01:01:23: Server started on 127.0.0.1:28015
01:01:23: Connecting to authentication server #1 ...
01:01:23: Server external IP: 127.0.0.1
01:01:23: Receiving authentication data from server #1 ...
01:01:23: Hardware ID: f42dffb20dd3a91339a8f1d56860c203
01:01:23: You can't run server with RustExtended on this IP with this port.
Please purchase this modification from a developer before to use.
01:01:33: Server started on 127.0.0.1:28015
01:01:33: Connecting to authentication server #1 ...
01:01:34: Server external IP: 127.0.0.1
01:01:34: Receiving authentication data from server #1 ...
Как среди всей этой информации получить именно то, что будет вместо f42dffb20dd3a91339a8f1d56860c203, для дальнейшей работы с данным значением?
int main() {
string s;
while (cin>>s) if (s == "ID:") break;
cin >> s; cout << "Ваш ID = " << s;
}
Ваш ID = f42dffb20dd3a91339a8f1d56860c203
Дешево и сердито. Это в С++, но в чистых сях тоже есть функции чтения отдельных слов из входного потока.
1.c [----] 22 L:[ 1+17 18/ 26] *(266 / 283b) 0034 0x022 [*][X]
#include <stdio.h>
#include <string.h>
void main(){
char buf[BUFSIZ];
char *id;
char *id_str="Hardware ID: ";
FILE *file=fopen("log","r");
while(!feof(file)){
fgets(buf,sizeof(buf),file);
id=strstr(buf,id_str);
if(id){
id+=strlen(id_str);
printf("Ya podebil: %s",id);
}
}
}
Продвижение своими сайтами как стратегия роста и независимости