CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Feb 2010
    Posts
    22

    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.

  2. #2
    Join Date
    Apr 2008
    Posts
    725

    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?

  3. #3
    Join Date
    Mar 2010
    Location
    Aalten, Holland
    Posts
    14

    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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured