Important alert: (current site time 7/15/2013 4:55:12 PM EDT)
 

VB icon

\ A Program That Displays Include Files

Email
Submitted on: 1/23/2005 2:48:38 PM
By: Brenton Andrew Saunders 
Level: Beginner
User Rating: By 6 Users
Compatibility: Microsoft Visual C++
Views: 20174
(About the author)
 
     A program that lists all the "#include" files in a C++ source/header file.
 
code:
Can't Copy and Paste this?
Click here for a copy-and-paste friendly version of this code!
 
Terms of Agreement:   
By using this code, you agree to the following terms...   
  1. You may use this code in your own programs (and may compile it into a program and distribute it in compiled format for languages that allow it) freely and with no charge.
  2. You MAY NOT redistribute this code (for example to a web site) without written permission from the original author. Failure to do so is a violation of copyright laws.   
  3. You may link to this code from another website, but ONLY if it is not wrapped in a frame. 
  4. You will abide by any additional copyright restrictions which the author may have placed in the code or code's description.
				
//**************************************
// Name: \ A Program That Displays Include Files
// Description:A program that lists all the "#include" files in a C++ source/header file.
// By: Brenton Andrew Saunders
//
//This code is copyrighted and has// limited warranties.Please see http://www.Planet-Source-Code.com/vb/scripts/ShowCode.asp?txtCodeId=8843&lngWId=3//for details.//**************************************

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
FILE *file;
char filename[_MAX_PATH];
void main()
{
re_open:
	system("cls");
	puts("Type in the name of the .cpp or .h file whose #include files are to be read:");
	gets(filename);
	system("cls");
	file = fopen(filename, "r");
	if(!file)
	{
		printf("The file '%s' could not be opened.\n", filename);
		system("pause");
		goto re_open;
	}
	else
	{
		int icount = 0;
		do
		{
			char line[256];
			fgets(line, 256, file);
			if(!strncmp(line, "#include", 8))
			{
				char *result;
				result = strpbrk(line, "<\"");
				result ++;
				result[strlen(result) - 2] = ' ';
				printf(result);
				icount ++;
			}
		}while(!feof(file));
		if(icount == 0)
		{
			puts("No #include files");
		}
		system("pause");
		fclose(file);
		goto re_open;
	}
}


Other 46 submission(s) by this author

 


Report Bad Submission
Use this form to tell us if this entry should be deleted (i.e contains no code, is a virus, etc.).
This submission should be removed because:

Your Vote

What do you think of this code (in the Beginner category)?
(The code with your highest vote will win this month's coding contest!)
Excellent  Good  Average  Below Average  Poor (See voting log ...)
 

Other User Comments

4/15/2007 3:05:00 AMgasim

مشكور جداً
(If this comment was disrespectful, please report it.)

 
4/16/2007 2:07:00 AMgasim

مشكر جداً
(If this comment was disrespectful, please report it.)

 
7/30/2007 5:25:51 AMclasses, frameworks, oop

classes, frameworks, oop
(If this comment was disrespectful, please report it.)

 
1/10/2009 1:37:33 AMcode proj

A Program That Displays Include Files
(If this comment was disrespectful, please report it.)

 

Add Your Feedback
Your feedback will be posted below and an email sent to the author. Please remember that the author was kind enough to share this with you, so any criticisms must be stated politely, or they will be deleted. (For feedback not related to this particular code, please click here instead.)
 

To post feedback, first please login.