AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   [HELP] Read a line from file (https://forums.alliedmods.net/showthread.php?t=229774)

m.touqeerafzal 11-14-2013 16:49

[HELP] Read a line from file
 
I want to read file but line by line....

code should return 1st line n after that next line... and so on until the file ends..

someone plzzzz help...

YamiKaitou 11-14-2013 16:58

Re: [HELP] Read a line from file
 
Look at the file natives (hint, fread)

fysiks 11-15-2013 01:22

Re: [HELP] Read a line from file
 
I already gave you an example. Are you that ******* lazy?????

m.touqeerafzal 11-15-2013 02:56

Re: [HELP] Read a line from file
 
Fysiks bro i'm not lazy..... but i did'nt get my desired thing....

in fgets function there is a argument of len of characters to be read....

but i don't know the exact number of characters... it would be different at every line...

so i just don't know how to solve this problem...

And bro don't be rude if someone don't understand....

Arkshine 11-15-2013 04:02

Re: [HELP] Read a line from file
 
new buffer[128]
fgets(handle, buffer, charsmax(buffer));

It's the size of your buffer, the max length in characters you can retrieve at once.
That's not something which will change on each line.
Just use charsmax(), which means sizeof buffer- 1, and that's it.

fysiks 11-15-2013 11:57

Re: [HELP] Read a line from file
 
Quote:

Originally Posted by m.touqeerafzal (Post 2061036)
And bro don't be rude if someone don't understand....

If you completely ignore advice given to you then you are being rude and deserves a response in kind (especially since the code does EXACTLY what you want). Also, don't call me "bro". I'm not your brother.

simanovich 11-15-2013 15:01

Re: [HELP] Read a line from file
 
Quote:

Originally Posted by fysiks (Post 2061191)
If you completely ignore advice given to you then you are being rude and deserves a response in kind (especially since the code does EXACTLY what you want). Also, don't call me "bro". I'm not your brother.

OT:
"bro" is also a Slang word in the Amrecian-English to call men.
PS: In hebrew, "אחי" ("bro", "ahi") is also have the same definition

@Back To The Topic
Here you go: https://forums.alliedmods.net/showthread.php?t=46218

Next time learn how to use the search button.

fysiks 11-15-2013 15:12

Re: [HELP] Read a line from file
 
Quote:

Originally Posted by simanovich (Post 2061257)
OT:
"bro" is also a Slang word in the Amrecian-English to call men.
PS: In hebrew, "אחי" ("bro", "ahi") is also have the same definition

You are telling me how to speak English? ROFLMAO! "bro" should NOT be used with people who are not your friend (IMO, shouldn't be used at all unless it was my brother).

m.touqeerafzal 11-18-2013 10:44

Re: [HELP] Read a line from file
 
thanx..Arkshine and simanovich

thanx guyz it was helpful :)

fysiks 11-19-2013 00:04

Re: [HELP] Read a line from file
 
Quote:

Originally Posted by simanovich (Post 2061257)

Just so people don't get bad advice, the file functions used in that thread should be avoided. fopen(), fgets(), fclose() functions should be used instead.

Quote:

Originally Posted by m.touqeerafzal (Post 2062392)
thanx guyz it was helpful :)

You're welcome . . .


All times are GMT -4. The time now is 23:13.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.