What im trying to do is, Read a line from a file but, i want to single out each word and save it into a String array, using the "Trim()" command? but i just cant do it, if you can point me in the right direction it would be nice ;D
well tanel he said each word your splitting each line
you could do like
C# aint open so just writing
Code:
string[] lines = File.ReadAllLines("mylines.txt");
foreach (string line in lines)
{
string[] words = line.split(' ');
}
thanks both of you :]
Code:
string[] lines = File.ReadAllLines(@"C:\Users\ADVENT\Documents\Questions.txt");
foreach (string line in lines)
{
string[] words = line.Split(' ');
for (int i = 0; i < words.Length; i++)
{
Console.WriteLine(words[i]);
}
}
got all the words to show in console, cheers its what i wanted ;]
string[] lines = File.ReadAllLines(@"C:\Users\ADVENT\Documents\Questions.txt");
foreach (string line in lines)
{
string[] words = line.Split(' ');
for (int i = 0; i < words.Length; i++)
{
Console.WriteLine(words[i]);
}
}
got all the words to show in console, cheers its what i wanted ;]
im getting confused, 1element in the array holds 3 words but in differant lines, so its possible to save the 3 words into 3 differant string variables?
im getting confused, 1element in the array holds 3 words but in differant lines, so its possible to save the 3 words into 3 differant string variables?
and thats pretty decent, you make it yourself?
yeah i was learning C++ a while ago from youtube videos and it had a guide somewhat similar and then i made this one a bit more advanced so it works good but yeah i made it
anyway on your thing is this what you kind of need? 3 diff words 3 diff strings
Code:
string a = "";
string b = "";
string c = "";
string[] lines = File.ReadAllLines(@"C:\Users\ADVENT\Documents\Questions.txt");
foreach (string line in lines)
{
string[] words = line.Split(' ');
for (int i = 0; i < words.Length; i++)
{
a = words[0];
b = words[1];
c = words[2];
Console.WriteLine(words[i]);
}
}
yeah i was learning C++ a while ago from youtube videos and it had a guide somewhat similar and then i made this one a bit more advanced so it works good but yeah i made it
anyway on your thing is this what you kind of need? 3 diff words 3 diff strings
Code:
string a = "";
string b = "";
string c = "";
string[] lines = File.ReadAllLines(@"C:\Users\ADVENT\Documents\Questions.txt");
foreach (string line in lines)
{
string[] words = line.Split(' ');
for (int i = 0; i < words.Length; i++)
{
a = words[0];
b = words[1];
c = words[2];
Console.WriteLine(words[i]);
}
}
thanks! ill play around with it for abit, so i get abit more familiar with it, cheers for your help
What im trying to do is, Read a line from a file but, i want to single out each word and save it into a String array, using the "Trim()" command? but i just cant do it, if you can point me in the right direction it would be nice ;D
This is not necessarily the most efficient way to do it but...
Code:
// using System.IO
// using System.Collections.Generic
public static string[] ReadAllWords(string File)
{
// Note: An exception will be thrown here if the file does not exist
string[] Lines = File.ReadAllLines(File);
List<string> Words = new List<string>();
foreach (string line in Lines)
{
foreach (string s in line.Split(' '))
Words.Add(s);
}
return Lines.ToArray();
}
This is not necessarily the most efficient way to do it but...
Code:
// using System.IO
// using System.Collections.Generic
public static string[] ReadAllWords(string File)
{
// Note: An exception will be thrown here if the file does not exist
string[] Lines = File.ReadAllLines(File);
List<string> Words = new List<string>();
foreach (string line in Lines)
{
foreach (string s in line.Split(' '))
Words.Add(s);
}
return Lines.ToArray();
}
This is not necessarily the most efficient way to do it but...
Code:
// using System.IO
// using System.Collections.Generic
public static string[] ReadAllWords(string File)
{
// Note: An exception will be thrown here if the file does not exist
string[] Lines = File.ReadAllLines(File);
List<string> Words = new List<string>();
foreach (string line in Lines)
{
foreach (string s in line.Split(' '))
Words.Add(s);
}
return Lines.ToArray();
}
I was playing around with it for abit and managed to make it do what i wanted :
Code:
public static string[] ReadAllWords()
{
// Note: An exception will be thrown here if the file does not exist
string[] Lines = File.ReadAllLines(@"C:\Users\ADVENT\Documents\Questions.txt");
List<string> Words = new List<string>();
foreach (string line in Lines)
{
foreach (string s in line.Split(' '))
Words.Add(s);
}
string[] ArrayWords = new string[Words.Count];
Words.CopyTo(ArrayWords);
for(byte i = 0; i < ArrayWords.Length ; i++)
{
Console.WriteLine(ArrayWords[i]);
}
return Lines.ToArray();
}
its probably terrible, but im working with stuff i aint used before such as lists. ill have a play around with it xD
Reading HP/MP/etc... 10/27/2009 - Aion - 2 Replies Hey All,
I'm sort of new to this memory offset, but I've currently got the BaseAddress of Game.dll and am looking for advice or direction in getting the target HP and stuff. I've seen the offset thread on these forums, I'm just unsure how to actually do the offset in C#.
Any direction would be appreciated :)
upon reading.... 07/01/2009 - Grand Chase - 23 Replies upon reading this forum.
i noticed that majority
is blaming the cheater
for being patch
well guys i want you
to under stand that
game guard will always be updated
every two or three weeks...
Problem when reading the downloaded files 02/26/2009 - Zero - 2 Replies Can anyone help me after i downloaded the .rar file then ill use my winRAR to extract it all it says is ! D:\Documents and Settings\Desktop\7234d1191457676-cheat-engine-disc ussion-submission-zeroonline.rar: The archive is either in unknown format or damaged
how can that be when its a small file so it wont be damaged? can anyone give me an advice. thank you Sirs..
[HELP]Writing and reading from *.ini files 02/18/2009 - CO2 Programming - 2 Replies i was trying to do that by myself but after 3days i must say that i cant do it :mad:
sooo i will be very happy if somebody could help me with it :)
thanks :)
Reading and Writing .INI Files 11/16/2008 - General Coding - 2 Replies CodeGuru: CIniFile - Class for Reading and Writing .INI Files
I found this information useful for starting out on understanding more about the code for read/write ini files. Maybe this will help some others (That are willing to read) :D
enjoy