-
April 26th, 2013, 01:59 AM
#1
geting a word from a text file in c++
hi im trying to have the nickanme set to be a random name from a text fille full of nickanmes i dont know
how to do it heres my code
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using FluorineFx;
using FluorineFx.Messaging.Adapter;
using FluorineFx.Messaging.Api.Service;
using FluorineFx.Net;
using System.Threading;
using System.IO;
namespace TinyChat_SPam
{
class Client : IPendingServiceCallback
{
private static Random rand = new Random();
static string[] colors = { "#1965b6", "#32a5d9", "#7db257", "#a78901", "#9d5bb5", "#5c1a7a", "#c53332", "#821615", "#a08f23", "#487d21", "#c356a3" };
static int colorIndex = 0;
public NetConnection mNetConnection;
private Thread thdHandler;
public string roomName;
public bool FlagDone = false;
public const string MsgPath = "message.txt";
public Client()
{
}
public Client(string roomName)
{
mNetConnection = new NetConnection();
mNetConnection.OnConnect += OnConnect;
mNetConnection.OnDisconnect += OnDisconnect;
this.roomName = roomName;
}
public void SetHandler(Thread thdHandler)
{
this.thdHandler = thdHandler;
}
private void OnConnect(object sender, EventArgs e)
{
if (mNetConnection.Connected)
{
Console.WriteLine("Connected.");
Thread.Sleep(200);
SetNick("O" + GetRandomString(10) + "G");
Thread.Sleep(200);
foreach (string msg in File.ReadAllLines(MsgPath))
{
SendMessage(new Message(msg));
Thread.Sleep(200);
}
}
FlagDone = true;
}
private void OnDisconnect(object sender, EventArgs e)
{
Console.WriteLine("Disconnected.");
thdHandler.Abort();
}
private void SetNick(string name)
{
mNetConnection.Call("nick", this, name);
}
private void SendMessage(Message message)
{
colorIndex++;
if (colorIndex >= colors.Length)
{
colorIndex = 0;
}
string tmp = message.Format(',');
string[] param = new string[] { tmp, colors[colorIndex] + ",en" };
mNetConnection.Call("privmsg", this, param);
}
private string GetRandomString(int length)
{
Thread.Sleep(25);
rand = new Random(DateTime.Now.Millisecond / new Random().Next(2, 5));
string tmpString = "";
while (length-- > 0)
{
tmpString += (char)rand.Next('a', 'z');
}
return tmpString;
}
public void ResultReceived(IPendingServiceCall call)
{
throw new NotImplementedException();
}
}
}
-
April 26th, 2013, 04:13 AM
#2
Re: geting a word from a text file in c++
What programming language is it? C#?
At least, it has nothing to do with Visual C++, nor is it a C...
Victor Nijegorodov
-
April 26th, 2013, 12:10 PM
#3
Re: geting a word from a text file in c++
-
April 26th, 2013, 12:17 PM
#4
Re: geting a word from a text file in c++
Then post it in C# forum!
Victor Nijegorodov
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|