C/C++ Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsProgrammingC/C++ Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old December 17th, 2004, 06:00 PM
piepes piepes is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Dec 2004
Posts: 7 piepes User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Someone compile this! i cant get it to!

this is the code that i need compiling, it says it needs headers but i cannot find them!


Code:
 
#include <stdio.h>
#include <sys/types.h>
#include <dirent.h>
#include <errno.h>
int main(int argc, char *argv[])
{
		DIR			 *dip;
		struct dirent   *dit;
		int			 i = 0;
		/* check to see if user entered a directory name */
		if (argc < 2)
		{
				printf("Usage: %s <directory>\n", argv[0]);
				return 0;
		}
		/* DIR *opendir(const char *name);
		 *
		 * Open a directory stream to argv[1] and make sure
		 * it's a readable and valid (directory) */
		if ((dip = opendir(argv[1])) == NULL)
		{
				perror("opendir");
				return 0;
		}
		printf("Directory stream is now open\n");
		/*  struct dirent *readdir(DIR *dir);
		 *
		 * Read in the files from argv[1] and print */
		while ((dit = readdir(dip)) != NULL)
		{
				i++;
				printf("\n%s", dit->d_name);
		}
		printf("\n\nreaddir() found a total of %i files\n", i);
		/* int closedir(DIR *dir);
		 *
		 * Close the stream to argv[1]. And check for errors. */
		if (closedir(dip) == -1)
		{
				perror("closedir");
				return 0;
		}
		printf("\nDirectory stream is now closed\n");
		return 1;
}


cheers

Reply With Quote
  #2  
Old December 17th, 2004, 06:43 PM
kode_monkey kode_monkey is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jul 2003
Posts: 367 kode_monkey User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 7 m 21 sec
Reputation Power: 6
What operating system and compiler are you using?

-KM-

Reply With Quote
  #3  
Old December 18th, 2004, 02:12 PM
loopy123 loopy123 is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Dec 2004
Posts: 13 loopy123 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Before I risk my system, whats the program do exactly, im unfamilar with some of those commands.

Reply With Quote
  #4  
Old December 20th, 2004, 07:20 PM
piepes piepes is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Dec 2004
Posts: 7 piepes User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
im using XP with Microsoft VS 6.0 standard compiler
it just basically saves the titles from the contents of a fonder to a text file i think!
i dont really know to be honest, a mate has asked me to compile it for him and it aint working! lol
but i am fairly sure that is what its for! lol

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingC/C++ Help > Someone compile this! i cant get it to!


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway
Stay green...Green IT