Read a text file and echo something if text exists?
Hello, I am trying to make it so when you enter a new line in a text file like this format:
ThisIsPlayersName 127.0.0.1
If the text you entered into the textbox matches either the IP or ThisIsPlayerName it echos the players name matching the ip, when it reads the text file it would be on a webhost e.g
www.example.com/banlist.txt
Could anybody help me do this?, Thanks.
Re: Read a text file and echo something if text exists?
where's the text box? do you enter a new line in the text box, or the web-hosted file? :confused:
Re: Read a text file and echo something if text exists?
Code:
#include <windows.h>
#include <stdio.h>
#include <iostream.h>
int main() {
string StringToRead;
char Playername[80], ip[80];
StringToRead = "Playername 127.0.0.1";
strcpy(Playername, strtok((char*)StringToRead.c_str(), " ")); /* strtok basicly splits the string with
the by you choses delimiter. */
strcpy(ip, strtok(NULL, "")); /* This makes the variable 'ip' hold the leftover of
the last time we strtok'd. */
cout << Playername << endl;
cout << ip << endl;
return cin.get();
}
This might help you o_o