Thanks for the help in advance!!
P.S. this is C not C++
FILE *fp;
char line[500]; //the line we are reading in
int current_line = 0; //current line loop is at
char* file; //filename
char mychar; int i = 1; //for traversal purposes
strcpy(file,prog_name);
strcat(file, ".c"); //prog_name is a global so we dont want to edit that
fp = fopen(prog_name, "r");
if(fp == NULL)
{
printf("error reading file bro");
}
else
{
while(fgets(line, 500, fp) != NULL && current_line < line_num)
{
current_line++;
}
mychar = line[0];
while (mychar != 0)
{
printf("%c", line[i]); i++;
}
printf("%s \n", line);
}
fclose(fp);
This post has been edited by chiguy: 03 April 2012 - 10:53 AM

New Topic/Question
Reply




MultiQuote





|