[haiku-development] Re: Help reading text file.

  • From: Fredrik Modéen <fredrik@xxxxxxxxx>
  • To: haiku-development@xxxxxxxxxxxxx
  • Date: Sun, 3 Aug 2008 19:52:23 +0200 (CEST)

Thanks everyone :)

I found that use this code was the easiest (perhaps not the BeOS way but
it can be changed when a read line class/function exist in Haiku)

FILE *file = fopen(str.String(), "r");
if (file != NULL) {
 char line [STRINGLENGTHCPY];
 while (fgets (line, sizeof line, file ) != NULL ) {
  int len = strlen(line);
  if (len > 0 && line[len-1] == '\n')
   line[len-1] = '\0';
  BuildFromJoystickDesc(line, info);
 }
 fclose(file);
}



-- 
MVH
Fredrik Modéen


Other related posts: