Click here to Skip to main content
15,896,269 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: how to generate text file for a program output? Pin
Richard MacCutchan24-Jul-14 2:11
mveRichard MacCutchan24-Jul-14 2:11 
GeneralRe: how to generate text file for a program output? Pin
mybm124-Jul-14 18:47
mybm124-Jul-14 18:47 
GeneralRe: how to generate text file for a program output? Pin
Richard MacCutchan24-Jul-14 20:35
mveRichard MacCutchan24-Jul-14 20:35 
AnswerRe: how to generate text file for a program output? Pin
CPallini24-Jul-14 2:46
mveCPallini24-Jul-14 2:46 
GeneralRe: how to generate text file for a program output? Pin
mybm124-Jul-14 18:49
mybm124-Jul-14 18:49 
GeneralRe: how to generate text file for a program output? Pin
mybm127-Jul-14 20:49
mybm127-Jul-14 20:49 
GeneralRe: how to generate text file for a program output? Pin
CPallini27-Jul-14 21:25
mveCPallini27-Jul-14 21:25 
Questionhow to display specific file in a folder using c program in ubuntu? Pin
mybm123-Jul-14 20:43
mybm123-Jul-14 20:43 
#include <sys/types.h>  // for scandir
#include <sys/dir.h>    // for alphasort and structure dirent 
#include <sys/param.h>  // for MAXPATHLEN and getwd
#include <stdio.h>
 
#define FALSE 0
#define TRUE !FALSE
 
extern  int alphasort();// extern extend the visiblity of the function alphasort 
                        //alphasort used as the comparison function for the scandir() line no 24 function to sort the directory
 
char pathname[MAXPATHLEN];
 
main()   { int count,i;
				struct direct **files;//pointer to a pointer ,which point to the object call files here
				int file_select();
 
				if (getwd(pathname) == NULL ) // return absolute file name of current directory
						{ printf("Error getting path\n");
								exit(0);
						}
				printf("Current Working Directory = %s\n",pathname);
				count =
				  scandir(pathname, &files, file_select, alphasort);//scandir returns the current directory (.) and the 									directory above this (..) as well as all files so we need to check
 
				/* If no files found, make a non-selectable menu item */
				if 		(count <= 0)
						{		 printf("No files in this directory\n");
								exit(0);
						}
				printf("Number of files = %d\n",count);
				for (i=1;i<count+1;++i)
						 printf("\n%s\n  ",files[i-1]->d_name);
				printf("\n"); /* flush buffer */
		}



int file_select(struct direct   *entry)
 { char *ptr;
   char *rindex(char *s, char c);
		 if ((strcmp(entry->d_name, ".") == 0) ||
						(strcmp(entry->d_name, "..") == 0))
						 return (FALSE);
  						 // checking of its extension 
						ptr = rindex(entry->d_name, '.');
				 if ((ptr != NULL) &&
						 ((strcmp(ptr, ".c") == 0) ||
						  (strcmp(ptr, ".txt") == 0) ||
						  (strcmp(ptr, ".m") == 0) ))
								 return (TRUE);
									else
									return (FALSE);
		}

debina

AnswerRe: how to display specific file in a folder using c program in ubuntu? Pin
mybm123-Jul-14 20:44
mybm123-Jul-14 20:44 
GeneralRe: how to display specific file in a folder using c program in ubuntu? Pin
Richard MacCutchan23-Jul-14 22:11
mveRichard MacCutchan23-Jul-14 22:11 
GeneralRe: how to display specific file in a folder using c program in ubuntu? Pin
mybm123-Jul-14 23:10
mybm123-Jul-14 23:10 
QuestionRe: how to display specific file in a folder using c program in ubuntu? Pin
Richard MacCutchan24-Jul-14 0:27
mveRichard MacCutchan24-Jul-14 0:27 
AnswerRe: how to display specific file in a folder using c program in ubuntu? Pin
mybm124-Jul-14 0:39
mybm124-Jul-14 0:39 
GeneralRe: how to display specific file in a folder using c program in ubuntu? Pin
Richard MacCutchan24-Jul-14 1:04
mveRichard MacCutchan24-Jul-14 1:04 
GeneralRe: how to display specific file in a folder using c program in ubuntu? Pin
mybm124-Jul-14 1:24
mybm124-Jul-14 1:24 
GeneralRe: how to display specific file in a folder using c program in ubuntu? Pin
Richard MacCutchan24-Jul-14 1:38
mveRichard MacCutchan24-Jul-14 1:38 
GeneralRe: how to display specific file in a folder using c program in ubuntu? Pin
mybm124-Jul-14 1:41
mybm124-Jul-14 1:41 
QuestionVisual studio 2010 - class wizard Pin
Member 1095872123-Jul-14 16:58
Member 1095872123-Jul-14 16:58 
AnswerRe: Visual studio 2010 - class wizard Pin
Stefan_Lang24-Jul-14 23:25
Stefan_Lang24-Jul-14 23:25 
QuestionHow to connect and access a SQLite database via C++ Pin
sarah0023-Jul-14 8:26
sarah0023-Jul-14 8:26 
AnswerRe: How to connect and access a SQLite database via C++ Pin
Richard Andrew x6423-Jul-14 8:39
professionalRichard Andrew x6423-Jul-14 8:39 
GeneralRe: How to connect and access a SQLite database via C++ Pin
PIEBALDconsult23-Jul-14 8:48
mvePIEBALDconsult23-Jul-14 8:48 
QuestionHow do you do data exchange (as in DDX_ functions/macros).... Pin
Member 1095872123-Jul-14 5:50
Member 1095872123-Jul-14 5:50 
QuestionIcons are displayed as black squares on remote desktops Pin
APSAccounts23-Jul-14 4:36
APSAccounts23-Jul-14 4:36 
AnswerRe: Icons are displayed as black squares on remote desktops Pin
Richard Andrew x6423-Jul-14 5:02
professionalRichard Andrew x6423-Jul-14 5:02 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.