C++ :: How To Include Path To A Folder From Current Directory

Jun 8, 2012

I've forgotten how to include a path to a folder from my current directory!

I mean, instead of loading my dice images as "dice6.png", I'm trying to load them from a file, as ".Imagesdice6.png"

Not sure why, but this isn't working. Google searching has got me nowhere.

View 1 Replies


ADVERTISEMENT

C/C++ :: Include (Text) Files From Directory (1 By 1) Automatically And Print It

Jun 10, 2014

#include<iostream>
#include<conio.h>
#include<fstream>
#include<windows.h>
using namespace std;
int main(){
string ptr,a;
string b="E:project";

[Code] ....

View 4 Replies View Related

C++ :: Boost Wave Tool Not Find Default Include Directory?

Jun 2, 2013

I have built the wave tool and now am trying to run my source code through it. But it just doesn't want to find the include directory. I just don't understand. Here's my command:

#include <stdio.h>
#include <vector>
#include <map>
#include <string>

Perhaps it how I built it since there is no info on how to do this? I just ran ../b2.exe from the boost_1_53_0/tools directory.

I'm running CYGWIN_NT-6.1-WOW64 TARDIS 1.7.18(0.263/5/3) 2013-04-19 10:39 i686 Cygwin with a g++ version of 4.5.3. g++ has no problem finding the default include directory (I don't have to specify the -I switch). The -I switch doesn't seem to work for any of the other include directories that I wan to use either, but I want this cleared up before I get into that since it might be related.

View 2 Replies View Related

C++ ::  Default Document Folder Path

Mar 12, 2013

im trying to write a file to a default document folder..something like...

FILE* file;
file = fopen("%docdir% est.txt", "w");
fputs("Hello", file);
fclose(file);
"%docdir% est.txt" this isnt working for me, i have to write it as
"C:userspublicdocument est.txt"

any method to write directly to default document folder so it will work in most Windows ? for example in windows 7 this is the default folder "C:users publicdocument est.txt" in windows XP its different

i have to detect the windows version first, to write the correct path

View 3 Replies View Related

C++ :: Windows Path - Folder Of Execution

Jan 17, 2014

This question is currently only for windows; but I would like to know about a cross-platform way to perform what I want to do (explained below) -

I have created a little program:

#include <iostream>
int main(int argc, char *argv[]) {
for (int i = 0; i < argc; ++i) {
std::cout << argv[i] << '
';
} }

I have added this program to the windows PATH. I put this program in C:Program FilesProgram

I now navigate to C:DataVariousTexts using CMD.

Then I type in: "program x"

The program will print out "program x" as by default. What I would like to get hold of is the folder in which the program is actually being called. ( I want to somehow get "C:DataVariousTexts" to be read into my program ).

How do I perform such an operation?

View 5 Replies View Related

C++ :: Output Only Few Files Using Regex From Current Directory

Nov 20, 2013

I'm trying to output only a few files, using regex, from the current directory, this is my main code:

Code:
// main.cpp
{
char * _dir = new char[MAX_PATH];
getcwd(_dir, MAX_PATH);
unique_ptr<CExtractor> _ptr(new CExtractor(_dir));
delete[] _dir;
}

Code:
// CExtractor.cpp
DIR *pdir = NULL;
struct dirent *pent = NULL;
pdir = opendir(_cwd.c_str());
while ((pent = readdir(pdir)) && (pent->d_type != DT_DIR)) {
if (regex_match(pent->d_name, regex(".(in|txt)$"), std::regex_constants::icase)) {
cout << pent->d_name << endl;
}
}
closedir(pdir);

My code is compiled correctly, but when I run my binary, nothings is outputed..here are my files in the current directpory:

aclocal.m4 config.guess config.status depcomp m4 NEWS
AUTHORS config.h config.sub INSTALL Makefile README
autom4te.cache config.h.in configure install-sh Makefile.am src
ChangeLog config.h.in~ configure.ac libtool Makefile.in stamp-h1
compile config.log COPYING ltmain.sh missing

I have a few "in" files

View 1 Replies View Related

C++ :: Comparing Images In Current Directory And Sub-directories

Jun 4, 2012

I am currently working on a program that will take an image and compare it with all other images in the current directory and sub-directories. I decided to use Qt for this as Qt has a QImage class with an overloaded == operator. This seems to work well if there are duplicates of the same size.

However, my goal is to not only find duplicate images of the same size, but the same image which may be a different size. To do this, I shrink the larger image to the size of the smaller image using the QImage scaled function.

The concern I have with this is that the scaling isn't done the same way the smaller image may have been scaled. I tested this by shrinking a copy of a picture in Paint, that image does not get deleted. I believe that == is looking for an identical image, so when I do the shrinking (via that scaled function), even if it is of the same picture I shrunk in Paint, the two methods of shrinking are not identical, and so the images appear different.

Any better method I can try? Something that can allow for slight deviations, such as an image being 99% "the same" as another. (I admit here that I will need to define some metric for what "the same" means.) In this case, the method assumes they are "identical" and gets rid of one of them.

The main way I can think of doing this is to go through each image, one pixel at a time. If the two pixels from the different images at the same index are the same, then I can increment a same pixel counter. If this number is 99% (or some other threshold) of the total pixel count, I can make the assumption the images are the same.

View 6 Replies View Related

C :: Function That Gets As Parameter File And Folder Path

Oct 18, 2014

I'm writing a small function that gets as parameter a file's path and a folder's path, and copies the given file to that folder.

Code:
int copy_file(const char* source, const char* folder) {
char copy[PATH_MAX];
strcpy(copy, folder);
strcat(copy, "/");
strcat(copy, source);

[Code] ....

Basically, this function purpose is to make a backup of source in folder every X minutes (depending on user's input).

The problem is the second call to open():

This call attempts to open the file for writing, and creates it if it is not already exist.

It also truncates it before writing to it - and that's my concern:

Let's say this is the second time this function runs, so copy is already exist. open() will then truncate it, and then one of the system calls in the while loop fails.

In this situation, I might be left with no backup file.

The problem also arises for when source is a read-only file:

If source is a read-only file, and copy is not already exist (meaning - it's the first backup attempt), then everything's fine, but, if source is a read-only file and copy is already exist, then I have to first remove copy altogather, and make a fresh copy of source.

Making a backup with new name for copy every time copy_file() runs, will solve this problem, and how can this be accomplished?

I should say that I'd really prefer that copy and source will have the same names when copy_file() returns...

View 5 Replies View Related

C/C++ :: Create A Directory / Folder Using It In Visual Studio

Jan 26, 2014

C-> Visual studio 2010-> windows 7

How to create a directory / folder.( to browse/save my files to a directory.) how to specify the path?

I googled , but i cant able to find appropriate as it is showing all in the C#, C++ , objective C. But not in C.

Here i am writing a sample program to my POS device .problem here is it is not taking mkdir(direct/dir.h header file)function. Any alternative is there to make a directory?

View 1 Replies View Related

Visual C++ :: Menu Item To Explore Current Path

Feb 21, 2015

I quite often use an ide written in assembler: RadAsm3[URL] .....

It has a menu item to explore current path. I have used other ide's that have a similar feature but:

The one in RadAsm3 will activate a current Explorer window if the current path is the same as the one requested.
All others open a new Explorer window.

I would like to implement the RadAsm3 approach using Visual Studio 2013 Community c++ as my host compiler for testing.

I tried to get the title of current windows but it appears ShellExecute "explore" does not produce a conventional window???

View 1 Replies View Related

Visual C++ :: Get Path To Recycle Bin Folder For Specific Drive?

May 29, 2014

there's a way to get a path to the recycle bin folder for a specific drive for the current user?

Say, on the input one provides "C:" and on the output you get "C:$Recycle.BinS-1-5-18"

View 10 Replies View Related

Visual C++ :: How To Set Starting Root Directory That Selects A Folder Name

Jan 22, 2013

The following code is useful to allow a user to select a particular folder in the disk directory.

Code:
void OpenFolder() {
LPMALLOC pMalloc; //,pMalloc2;
CString strDirectory;
BROWSEINFO bi;
// Gets the Shell's default allocator
wchar_t pszBuffer[MAX_PATH];

[Code] ....

However, if one uses this code over and over, one quickly becomes tired of threading one's way all the way from root directory C:. There is undoubtedly some way to designate a starting directory. The most obvious candidate to set such a target is the:

Code:
bi.pidlRoot = NULL;

But attempting to set bi.pidlRoot to a CString (directory address) errors because 'no suiitable conversion from CString to LPCITEMIDLIST exists'

How can I set the code to open at a designated address in the directory tree?

View 14 Replies View Related

C Sharp :: Copying A File From Current Directory To System Drive

Feb 8, 2014

I have tried to use File.Copy and File.Move but non of them would work as I expected .....

View 1 Replies View Related

C++ :: How To Get Browse Directory Dialog To Update Text Box With Path Selected

Jan 8, 2013

I'm trying to get a Browse Directory dialog to update a text box with the path selected. I had it working fine in Unicode build but now using TCHAR - I see the variable contains the correct path, but the textbox only gets updated with a single weird character.

setting the text checking WM_COMMAND vars-

Code:
SetWindowText(textBox2,&buttonPush(hWnd));

browse function when Browse button is pressed -

Code:
TCHAR& buttonPush(HWND hWnd) {
BROWSEINFO bi;
TCHAR szDir[MAX_PATH];
LPITEMIDLIST pidl;
LPMALLOC pMalloc;
if (SUCCEEDED(SHGetMalloc(&pMalloc))) {

[Code] ....

View 7 Replies View Related

C++ :: Splitting Directory Path Up - Function Call Missing Argument List

Feb 14, 2014

Code:
void CFileManager::SplitHeader(std::string sFilePath) {
std::string sDrive(255, ');
std::string sDirectory(255, ');
std::string sFileName(255, ');
std::string sExtension(255, ');

_splitpath_s(&sFilePath[0], &sDrive[0], sDrive.size, &sDirectory[0], sDirectory.size, &sFileName[0], sFileName.size, &sExtension[0], sExtension.size);
}

Which gives me error

Error 1 error C3867: 'std::basic_string<char,std::char_traits<char>,std ::allocator<char>>::size': function call missing argument list; use '&std::basic_string<char,std::char_traits<char>,st d::allocator<char>>::size' to create a pointer to member.

View 9 Replies View Related

C/C++ :: Count Files And Directories In Root Folder With Every Folder Information

Jul 25, 2013

I need a code in c++ . It should count the Files and Directories in root folder with every folder information i need the below information

1) no of files and folder
2) how many files are there in each folder
3) with size of every folder and files it contains

I am new in c++ ....

View 1 Replies View Related

C/C++ :: How To Include Whitespace In Queue

Feb 21, 2014

my code is already finished. im using parallel queues and im having problem in the queue customer name if i dont input space the code is fine but if i input space in the name it skips the bagcode and immediately jump to the number of bags what can i do to include the white spaces in the customer name and push it to the queue?

here's my code

#include <iostream>
#include <string>
#include <queue>
#include<conio.h>
using namespace std;
int main() {
queue<string> customer;

[code].....

View 3 Replies View Related

C++ :: Include Function From Header File?

Feb 21, 2013

I am trying to include a function from a header file named headerfunt.h . The code of my header file is

Code:
#ifndef HEADERFUNCT_H_INCLUDED
#define HEADERFUNCT_H_INCLUDED
#include <iostream>

[Code]....

But, while compiling it says abs was not declared... I have included the file.

View 2 Replies View Related

C++ :: Complex If Statement Does Not Include NOT Operator

Feb 7, 2015

I'm not sure if I was some weird syntax problem or the way Ive ordered things. But a conditional statement I have created is not performing the way I want it to.

else if ( !( xDif == -1 && yDif == 1 && prevXDif == 1 && prevYDif == 0 ) )
{
foundArr[lastX][lastY] = 1;
}

When debugging, the condition was activated with the values:

xDif = -1
yDif = 1
prevXDif = -1
prevYDif = 0

However, I want the condition not to follow through as I am using the 'NOT' or '!' operator to negative the entire statement. For some reason, the line of code within the else if is still running.

View 2 Replies View Related

C++ :: How To Include JPEG File Into A Program

May 3, 2013

How to include a jpeg file into a c++ program??

View 2 Replies View Related

C++ :: Unable To Open Include File?

Oct 16, 2013

my programme showing error 'unable to open inclde file ****' i fallowed the general procedure i.e., options-->directories--> ( inclde proper path) still not working..

View 2 Replies View Related

C++ :: How To Add Excel Library Or Include Headers

Jul 16, 2013

I want to read/write the excel sheet using C++. how to add the excel library or include the headers ?

Inot possible than is there any other way to work on Excel using C++.

View 4 Replies View Related

C/C++ :: Unable To Include A Header Into Application?

Aug 16, 2012

I've downloaded a file that I need to include in a new project. It's called phidget21.h and it's sat on my desktop. I've tried copying it to lots of various places. But I still can't get a new source file to compile. I think I haven't copied it to the right place yet. Where should I have copied it to?

#include <cstdlib>
#include <iostream>
#include <phidgets21.h>  

[Code]....

View 3 Replies View Related

C/C++ :: MSDOS Cannot Include Header Files?

Oct 13, 2012

msdos is present on my computer but it cannot include the header files but when i check all files are present but they still cannot include????????

View 1 Replies View Related

C++ :: Where To Put The Include Directive And Using Namespace Std With Multiple Files

Aug 23, 2014

I have two files that I want to compile:

main.cpp
Code:
#include <iostream>
using namespace std;
int ReadNumber();
void WriteAnswer();

[Code] .....

The compiler complains:
io.cpp||In function 'int ReadNumber()':|
io.cpp|3|error: 'cin' was not declared in this scope|
io.cpp||In function 'void WriteAnswer()':|
io.cpp|7|error: 'cout' was not declared in this scope|
io.cpp|7|error: 'endl' was not declared in this scope|

In io.cpp file, should I put the two statements ("include <iostream>" and "using namespace std") at the top, outside of the functions?

Or should I put the two statements inside each of the functions?

View 4 Replies View Related

C :: How To Include Single Header Files Into Project

Oct 2, 2014

I'm a beginner with C and wonder how to include single header files (*.h) in to my project. I mean header files which are not included to the standard installation package.

I thought it would work if I just copy the newheader.h file in to library folder c:MinGWinclude, but it didn't work. Is there some kinf of GCC -command or procedure to add these single header files or how it should work?

All of those standard header files are working well and I don't have any problems with them.

Environment I'm using is MinGW+GCC+Win7.

View 7 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved