Raised This Month: $ Target: $400
 0% 

Trouble with reading first line of a file


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Author Message
pillowCloud
Member
Join Date: Aug 2015
Location: AlliedModders
Old 08-04-2019 , 17:21   Trouble with reading first line of a file
Reply With Quote #1

Hi,
I had a trouble with reading the first line of a file, or to be more accurate, I found that the first character of the file is not something that appears on the actual file, for example:

my file looks like this:
PHP Code:
"pokemon" "pokemon.mp3"
"marko" "marko.mp3" 
but when I'm trying to print the first character of the file (witch shoud be "p"), it's gives me something else:


This causing me troubles when I'm trying to compare the SongName with a client input..
so here's my code:
PHP Code:
#include <amxmodx>

#define MAX_SONG_NAME 32
#define MAX_PATH_SIZE 64

#define CfgFile "addons/amxmodx/configs/cfg.txt"

new SongName[MAX_SONG_NAME];
new 
SongPath[MAX_PATH_SIZE];

new 
SongsLoaded;

public 
LoadSongs()
{
    if (
file_exists(CfgFile))
    {
        new 
text[64];
        new 
file fopen(CfgFile"r");
        
        while (!
feof(file))
        {
            
fgets(filetextcharsmax(text));
            
replace(textcharsmax(text), "^n""");
            if (
text[0] == ';' || !text[0]) continue;
            
            
console_print(0"[ test ] %c"text[0]);
            
console_print(0"[ test2 ] %s"text[0]);
            
            
parse(textSongNameMAX_SONG_NAMESongPathMAX_PATH_SIZE);
            
            
SongsLoaded++;
        }
        
        
fclose(file)
    }
    else
        
log_message("(Error) Failed to load file nostalgia.txt.");

Can someone explain me what am I doing wrong?
Thanks in advance.

Last edited by pillowCloud; 08-05-2019 at 01:08.
pillowCloud is offline
 



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 17:22.


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