0

hello,
can anyone help me for the following C++ program.
i want to write a program which reads a file of C language and
Print Lines of Codes and print signature of all function (including main) in that file.
please tell me either logic to develop this program or solution(code) for this.

kind regards.

3
Contributors
3
Replies
4
Views
9 Years
Discussion Span
Last Post by vmanes
0

you mean you want the program to read a *.c or *.cpp file then print all the function names ?

Start out with a very simple program that just opens the file and prints out each line. Post your code for that much and then we can talk about the rest of the program requirements.

0

hi,
i have made simple program that print lines of c file.
program :

#include<fstream.h>
#include<iostream.h>
#include<conio.h>
#define MAX 120

void main()
{
  ifstream f("file1.c");
  char buff[MAX];
  clrscr();
  while(!f.eof())
  {
     f.getline(buff,MAX);
     cout<<buff<<endl;
  }
}

now please tell me that how i identify that particular line is a function signature.

kind regards,

0

First off, the logic of testing for eof( ) before having read anything can cause your input/output to be off a bit - consider a dead empty file, and consider what happens after you read the last valid line in the file. This topic has been disussed many times in this (and other) forums - do a little searching.

That said, look over a bunch of code files. What character(s) must you look for to identify the fact that a function is (or may be) present on a given line? How do you further verify that you in fact have found a function?

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.