Help appreciated. Couldn't find any mention of this in "the book" (k&r).
|
Now I have two directory, all of header files *.h are included in directory /inc, while all of c file *.c are stored in /src directory.
The directory just like this, (/project ... |
I have c/gtk+ application and GList which filled three elements, when i try to run following code with gdb:
if (g_list_length(mw->img_list) > 0)
printf(">0");
else
printf("<0");
i see:
Program received ... |
The program is to open a directory and to display the name of the files...
i.e if there is a file..it should say FILE....else DIRECTORY..
but the program displays all the files ... |
i want to change this code below for the inwashfile to be able to load from any directory instead of loading from the tech_projects environmental variable.
/**Get projects directory from ...
|
I have a very simple program here, but it seems to be returning
a "true" value to the query S_ISDIR() even when the directory
entry is not a directory. Can any one pleeas ... |
I'm trying to create a downloader/update tool for my C application.
My updater PDL:
- Download update.xml from webserver
- Check update version by using fscanf and storing floating point to a variable
- Check variable with an ...
|
|
I want to get the files in folder and also in its subfolders.The following code does not get the files in its subfolder:
string[] files = Directory.GetFiles(txtFolderPath.Text, "*ProfileHandler.cs");
Can anyone Please tell me ... |
I'm writing a program to check if something is a file or is a directory. Is there a better way to do it than this?
#include <stdio.h>
#include <sys/types.h>
#include <dirent.h>
#include <errno.h>
int isFile(const char* ...
|
Is there any way to find out the parent directory of a file using C program. I would like to give same permissions for the file that the directory has. So ... |
i was trying to use clang to parse c++ code, but am unable to compile my source code because i am unable to find libclang headers.
I am running ubuntu 10.04 and ... |
We have a large C project with development happening on Linux, Mac OS and Windows. Most of our Windows developers use MSVC -- for example, the free edition of Visual ... |
How to writte a function that is to return all the file names in a directory including files in the sub directories.
So far, I have something like this, but it doesn't ... |
|
whenever, i try to open a file for writing using fopen("xyz.txt", "w"), i am able to create the file only in default C:\ drive. i want to create a directory in the process of running the c code and want to create the file in that directory. So, i would like to know: 1.) How to create a directory in c ... |
* Tong * Hi, I'm following the example in "C++ Templates: The Complete Guide", section 5.4 Template Template Parameters. It's basics/stack8.hpp example has a statement of "#include ", but I got an error for it. $ cat -n allocator.cc 1 #include 2 3 template< typename ALLOC = std::allocator |
I'm on a MacBook running mac osx 10.4.11, I have Xcode, gnu, and I'm using the terminal command: g++ -o helloworld helloworld.c I get the error: g++: error trying to exec 'cc1plus': execvp: No such file or directory What does this error mean? It means that your shell could find the g++ frontend of the GNU compiler but that frontend couldn't ... |
|
|
|
Hi, I need help. I want to read text files contained into a directory, but my program is unaware of how many files are contained into. In bash there's something similar to (figure out) for i in |
|
Hi, I'm wondering how to check for whether a file exists inside a given directory. I'm currently using an ifstream class to do this by passing the name of the file and checking for a .fail (alternatively, .bad) case, however I have a problem when I pass a directory to the ifstream object since both ifstream.fail() and .bad() return a false ... |
Hello NG, I have written some code which worked fine under c#. But i dont know, how this shoud work in c++. I have tryed much things, but i cant find out how to use DirectoryInfo and FileInfo under c++. Thanks for any hints! Peter Here is the c# code: // --------------------------------------------------------------------- // -- View *.prn Files in Directory // --------------------------------------------------------------------- ... |
"zjffdu" wrote: [color=blue] > Anyone know how to get the files in one directory?[/color] Yes, I know a bunch of ways. Since I don't know what operating system(s) you're using, I can't be very specific, but one approach is to use "system", like this (assumes DOS or Windows; alter as necessary for Unix, Linux, OS2, Mac, or whatever): #include ... |
Code: #include using namespace std; //Added // #include int main() { int product, quantity; double total = 0.0; // display headers cout << "Enter pairs of item numbers and quantities." << "Enter -1 for the item number to end input.\n"; cin >> product; while ( product != -1 ) { cin >> quantity; switch ( product ) // switch ... |
|
Hey everyone, I'm wondering if someone could help me. I want to write a small program that will be able to edit some perl script files. I need to load the text file and scan through it and then resave an edited copy. I can do this. What I need help with is there are many files and directorys containing these ... |
|
SOURCE_DIR = $(top_srcdir) SOURCE_INCLUDE_DIR = $(SOURCE_DIR)/../../include SOURCE_COMMON_DIR = $(SOURCE_DIR)/ SOURCE_LDSCRIPT_DIR = $(SOURCE_DIR) BUILD_DIR = $(top_builddir) BUILD_PROM_DIR = $(BUILD_DIR) CC=gcc CFLAGS=-c -Wall LDFLAGS=-M -T $(SOURCE_LDSCRIPT_DIR)/Linker.ld SOURCES= Main.c \ ErrorHandler.c \ ScriptProcess.c \ Queues.c \ Commands.c \ Processes.c \ Utilities.c \ Executive.s \ time.o \ $(SOURCE_COMMON_DIR)/Esr.c \ $(SOURCE_COMMON_DIR)/bitset.s OBJECTS=$(SOURCES:.c=.o) EXECUTABLE=Program1 all: $(SOURCES) $(EXECUTABLE) $(EXECUTABLE): $(OBJECTS) $(CC) $(LDFLAGS) $(OBJECTS) -o $@ .c.o: $(CC) $(CFLAGS) ... |
Hi! I'm trying to loop through a bunch of images for processing in a C program. I'm having trouble finding a tutorial or anything on how to do it. I'm essentially looking for some kind of for/while loop that can open the file, pull some info out of it, close it and then move on to the next one until it ... |
|
int main(int argc, char* argv[]) { DIR *pdir; struct dirent *pent; struct stat statbuf; if(argc>1) { pdir=opendir(argv[1]); } else { pdir=opendir("."); } //chdir(pdir); if (!pdir){ printf ("opendir() failure; terminating\n"); exit(1); } while ((pent=readdir(pdir))!=NULL) { stat(pent->d_name,&statbuf); if(strcmp(".", pent->d_name) == 0 || strcmp("..", pent->d_name) == 0) continue; if(S_ISDIR(statbuf.st_mode)) printf("%s \n", pent->d_name); if(!(S_ISDIR(statbuf.st_mode))) printf("%s %d\n", pent->d_name, statbuf.st_size); } closedir(pdir); return 0; } |
|
|
|
|
/* declare variables */ char original_file[256]; //char duplicate_file[256] = "\"C:\\Program Files\\File Manager\\"; char duplicate_file[256] = "C:\\Program Files\\File Mananger\\"; FILE *org,*dup; char ch; /* gather the file's name */ printf("Enter the name of the original file: "); scanf("%255s",&original_file); fflush(stdin); if(strlen(original_file) == 0) error_exit("Missing filename"); //strcat(original_file,"\""); //Add a quote at the end of the original file's name. strcat(duplicate_file,original_file); //Combine the destination directory and ... |
|
|
|
|
I have a project that I need to complete to run unattended on windows computer. I would like to schedule it to run at a set interval or to have it watch a folder for activity and then process the files. I have heard that C is a good programming language to use and am hoping that I can accomplish this ... |
|
#include #include FILE * open_file_in( const char *path, const char *filename, const char *mode ) { char buf[BUFSIZ]; strcpy(buf, path); strcat(buf, filename); return fopen(buf, mode); } int main(void) { FILE *in = open_file_in("C:\\", "test.txt", "r"); char ch; if (!in) { perror(NULL); } while ((ch = getc(in)) != EOF) { putc(ch, stdout); } fclose(in); return 0; } |
Thanks for the link. But, to be honest I don't think I put "it doesn't work" - I just wanted some advice. And as for helpless-ness, I would assume that the solution to 100% of all posts on every forum can be sourced from somewhere else on the internet - but I must be mistaken in assuming that forums were for ... |
There is actually an ansi way of doing this. You should look into dirent.h. Try something like this out: (NOTE: much of this was from "The C Programming Language") Code: #include #include #include #include #include #include void dirwalk(char *dir, void (*fcn)(char *)) { char name[1024]; struct dirent *dp; DIR *dfd; if((dfd = opendir(dir)) == NULL) ... |
|
hi everyone, How to display the files in a directory? And how to change a name of a file using sprintf? char filename[1000]; sprintf(filename,%s,stringName); // stringName is user inputed name rename(file,filename); Is there any way we can change the directory of filename? normally after change the name it located in the same directory as the file. any idea on how to ... |
This is one of those things that are OS-dependent, such that we would need to know what OS you're using in order to answer your question. It was only by chance that you dropped a clue, that directory path, which indicates that this is for either UNIX or Linux. The answer for Windows would have been different. It's been quite a ... |
|
I looked on http://xmlsoft.org/ for a developer package. I did not find it. (That suggestion about my problem with include mysql.h was exactly correct.) Is it possible that the /usr/lib/libxml2.so.2.6.26 is there to support an application installed on the server but the whole libxml2 package has not been installed on my server? Thanks, John |
Linux server, gcc ver 4.1.2, and MySQL ver 14.12 distrib 5.0.22 When I include in my my_prg.c the line "#include ;" I get the compile error: "mysql.h: No such file or directory". my_prg.c compiles and runs without error if I eliminate the "#include ". As far as I can tell, mysql.h does not exist on the server. It is not in ... |
|
Hi all, i was curious to know how would i program a function to create a file into any directory. For example. Most windows dirs begin with c:\ But what if they have a custom dir? Like E:\ or H:\ ? I would just like to know if i can make a function that will add a file in the folder ... |
Code: Hi, I have such a problem: The file structure is like follows: D1 D2 ...... Dn | | ....... | D11 D12 D13 etc. D21 D22 D23 | | ..... | f11 f12 f13 etc. f21 f22 f23 fn Files are under directories D1, D2, Dn, which are the highest directory name, and D11, D12, etc are sencondary directory name, ... |
I am programming in C on a Plan9 machine, but I have run into a problem. I was told that there was a system/library call called: Dir *dirtest(), which tests to see if an argument is a directory, but I cannot find any documentation, either in the Plan9 manual pages, or on Google, about any such system/library call. Does anyone here ... |
Hi, first of all, sorry about my poor english. I'm using ReadDirectoryChangesW to find what changes happen inside a directory (and subdirectories). But i could only get a path name and an action (FILE_ACTION_ADDED, FILE_ACTION_REMOVED, etc). How could i find if the change affects a directory or a file? Any simple way to do it? Thanks. |
Basicalyl what I am doing is using FindFile() and FindNextFile to enumerate to find media files and directories. I can get the media files using the filename string, but I can't figure out how to check if it is a directory or not. In earlier attemps I used to a file pointer to try to open it for reading, and if ... |
Can anyone point me to reference or even a tutorial on file and directory manipulation in a win32 environment? Presently, I'm using dos system calls to create directories, move files using wild cards, stuff like that. Basically, I want to set up a spool directory and have any files that land in that directory moved to directories I designate based on ... |
My compiler is bcb(borland c++ builder). Heres my plan, I'm am trying to load Lua script files, I thought maybe the best way to load the scripts onto memory is a TStringList. I want TStringList to search a certain directory and load all the files with the extension .lua in that directory, But I do not know how. Can anyone out ... |
i need some help / correction of the code to enable me to merge multiple text files into a final.txt, and then, delete every files which have been created, except final.txt currently, i have suceed in listing files on a directory. now, it's just the problem of reding the datas from the file, and direct merge it + delete the file. ... |
mike@nergal ~/projects/misc $ ./a --recurse --root /cygdrive/e/mike/projects/misc dirent 0 = #adaptutil.h# dirent 1 = . . is directory... dirent 2 = .. .. is directory... dirent 3 = Makefile ... dirent 12 = util util is directory... Recursing into /cygdrive/e/mike/projects/misc/util... dirent 0 = . . is directory... dirent 1 = .. .. is directory... dirent 2 = avl.c ... dirent 23 ... |
|
Im trying to add filenames from a directory to an itembox. I modified the code @ URL to look like this: Code: #include "stdafx.h" #include #include #include using namespace std; void listDir(const char * sdir, int count){ string str, strDir, str1; struct _finddata_t c_file; long hFile; // Find first file in current directory str = sdir + (string) ... |
|
Hello I am currently working on a project which scan a file and extracts relevant data from it. I have designed a program which does what I need and it works fine for one file. What I would like to know, is there way that my program can access a file in a particular directory, use it and then move to ... |
How do i loop through files in a directory? Posted on: 07/13/2003 13:48:02 Here are two *examples* (recursive and non-recursive). Alternatively, you may use DirectoryInfo/FileInfo. public static void Perform(String directoryName) { String[] fileNames=Directory.GetFiles(directoryName); for (Int32 i=0;i |
|
|
/* Compile options needed: none - The following program is a simple example which sends and receives one character to/from COM1: */ #include #include void main(void) { unsigned com1_status; unsigned com1_send; unsigned com1_rec; unsigned com1_init; int result, mask; /* open serial port at 1200 baud, 8 data bits, ** No parity, 1 stop bit */ com1_init = _bios_serialcom(_COM_INIT, 0, ... |
#include #include #include #include void main (int) { int gdriver=DETECT,gmode,errorcode; //Requesting auto-detection. int midx,midy,x; //Initializing graphics and local variables. initgraph(&gdriver,&gmode,"d:\\bc3\\bgi"); //Reading result of initialization. errorcode=graphresult(); if(errorcode!=grOk) //An error occurred. { printf("Graphics error occurred : %s \n",grapherrormsg(errorcode)); printf("Press any key to stop : "); getch(); exit(1); //Terminate the program due to error. } /*Changing the foreground color. Note ... |
|
Click to Expand / Collapse Quote originally posted by Dave Sinkula ... For starters: are you really programming for DOS? Plain old DOS. Not a Win32 console or anything, but 20-year-old DOS? why ? what's the problem ? DOS is a good starting point as well as win32 . The DOS and the Win32 is different flactforms that support different ... |
|
|
|
|
Is there a way to delete multiple files in a directory from C? I know there is the "remove" function...but, I think that is only to remove a single file, correct? What I'm looking for is something like "remove(*.dat)". Is that possible? If not, does someone have a simple algorithm that maybe loops though the *.dat files in a directory, and ... |
No.It wouldn't be hard though, especially with no error checking.[code]void cp(char *arg1, char *arg2) {FILE *one,*two;char buf[512]; one = fopen(arg2,"r"); two = fopen(arg1,"a"); while ( (fgets(buf,512,one)) != ... |