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.

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.

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,

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?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.