Raised This Month: $ Target: $400
 0% 

[HELP] Read a line from file


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
m.touqeerafzal
Member
Join Date: May 2013
Old 11-14-2013 , 16:49   [HELP] Read a line from file
Reply With Quote #1

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...
__________________
N e [X] u $
m.touqeerafzal is offline
Send a message via Skype™ to m.touqeerafzal
YamiKaitou
Has a lovely bunch of coconuts
Join Date: Apr 2006
Location: Texas
Old 11-14-2013 , 16:58   Re: [HELP] Read a line from file
Reply With Quote #2

Look at the file natives (hint, fread)
__________________
ProjectYami Laboratories

I do not browse the forums regularly anymore. If you need me for anything (asking questions or anything else), then PM me (be descriptive in your PM, message containing only a link to a thread will be ignored).
YamiKaitou is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 11-15-2013 , 01:22   Re: [HELP] Read a line from file
Reply With Quote #3

I already gave you an example. Are you that ******* lazy?????
__________________
fysiks is online now
m.touqeerafzal
Member
Join Date: May 2013
Old 11-15-2013 , 02:56   Re: [HELP] Read a line from file
Reply With Quote #4

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....
__________________
N e [X] u $
m.touqeerafzal is offline
Send a message via Skype™ to m.touqeerafzal
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 11-15-2013 , 11:57   Re: [HELP] Read a line from file
Reply With Quote #5

Quote:
Originally Posted by m.touqeerafzal View Post
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.
__________________

Last edited by fysiks; 11-15-2013 at 11:58.
fysiks is online now
simanovich
AlliedModders Donor
Join Date: Jun 2012
Location: Israel
Old 11-15-2013 , 15:01   Re: [HELP] Read a line from file
Reply With Quote #6

Quote:
Originally Posted by fysiks View Post
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.
__________________
simanovich is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 11-15-2013 , 15:12   Re: [HELP] Read a line from file
Reply With Quote #7

Quote:
Originally Posted by simanovich View Post
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).
__________________
fysiks is online now
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 11-19-2013 , 00:04   Re: [HELP] Read a line from file
Reply With Quote #8

Quote:
Originally Posted by simanovich View Post
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 View Post
thanx guyz it was helpful
You're welcome . . .
__________________

Last edited by fysiks; 11-19-2013 at 00:05.
fysiks is online now
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 11-15-2013 , 04:02   Re: [HELP] Read a line from file
Reply With Quote #9

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.
__________________

Last edited by Arkshine; 11-15-2013 at 04:02.
Arkshine is offline
m.touqeerafzal
Member
Join Date: May 2013
Old 11-18-2013 , 10:44   Re: [HELP] Read a line from file
Reply With Quote #10

thanx..Arkshine and simanovich

thanx guyz it was helpful
__________________
N e [X] u $
m.touqeerafzal is offline
Send a message via Skype™ to m.touqeerafzal
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


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


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