Skip to main content

Thread: Reading data from a file and printing it, in C programming language


i trying read file , print data screen. code looks far.

code:

#include <stdio.h>
#include <string.h>
#include <stdlib.h>

char a[50];
int i;



file *fp;

int main()
{


fp = fopen("psv101data.rtf", "r");
(i=1; <= 47; i++)
{fscanf(fp, "%s\n", a[i]);
printf("%s/n", a[i]);}
fclose(fp);

return 0;
}


output

(null)/n(null)/n(null)/n(null)/n(null)/n(null)/n(null)/n(null)/n(null)/n(null)/n(null)/n(null)/n(null)/n(null)/n(null)/n(null)/n(null)/n(null)/n(null)/n(null)/n(null)/n(null)/n(null)/n(null)/n(null)/n(null)/n(null)/n(null)/n(null)/n(null)/n(null)/n(null)/n(null)/n(null)/n(null)/n(null)/n(null)/n(null)/n(null)/n(null)/n(null)/n(null)/n(null)/n(null)/n(null)/n(null)/n(null)/

trying read 1 line @ time , output 1 line @ time. suggestions appreciated.

hey man,

looking first attempt , seem on right lines, ever think of trying use fget()? try this

php code:
#include <stdio.h>

int main() {
  
file *fp;
  
char line[100];

// open the file for reading
 
fp fopen("psv101data.rtf""r");
// loop through all lines in the file until we hit the last one
  
while( fgets(linesizeof(line), fp) != null ) {
    
// print the line data
    
printf("line %s"line);  
  }
 
// close the file we're done with it
  
fclose(infile); 

give shot , let me know happens! c's bit hazy think that's go!


Forum The Ubuntu Forum Community Ubuntu Official Flavours Support General Help [ubuntu] Reading data from a file and printing it, in C programming language


Ubuntu

Comments

Popular posts from this blog

How to change text Component easybook reloaded *newbee* - Joomla! Forum - community, help and support

After Effect warning: A problem occurred when processing OpenGL commands

Preconditions Failed. - Joomla! Forum - community, help and support