C/C++ :: Assign Path For The Files In For Loop?

Jan 6, 2015

I wrote this code but it opens file in its folder Iwant to save in somewhere else. How I could assign path for the files in for loop?

for (double j = 0.5; j < 1.4; j+=0.1) {
s +=1;
stringstream a;
a << j;
filename = "Vzcr_" + a.str();
filename += ".txt";
files.open(filename.c_str(), ios::out);

View 1 Replies


ADVERTISEMENT

C/C++ :: Getting All Files And Subfolders In Given Path?

Sep 1, 2014

basically I need to list all of files and subfolders and files inside them etc till all paths has been inspected, read data from every single object and pack it all into a single file.

I did not want to use boost or minizip because it seems too much for something so easy so I just wrote it myself via dirent - everything works fine I just have problem with directories and files with non ANSI character in titles (I'm from Poland) like ąęoźż etc. I can open them without problem and read all data from them but when I pack their's filename to std::string - it gets corrupted and happend to be for example:

TEST~1 instead of TESTąę

Just a note that data inside files is being written without problems - all special characters are stored without problems.

Code:

#include <list>
#include <string>
#include <dirent.h>
#include <cstdio>
#include <windows.h>
typedef struct {
std::string path;
unsigned lenght_of_path;

[code].....

I have already tried using std::wstring and Wide Characters function from dirent.h but I have failed.

View 3 Replies View Related

C++ :: Where Is The Path For Header Files For Mac Xcode

May 27, 2013

I want to include turboc.h file for some project

where do i have to add this file for mac xcode?

View 1 Replies View Related

C++ :: Path To Library Files In Search Directories

Dec 28, 2014

Using CodeBlocks. I've added the path to the library files in 'search directories' in 'linker' tab.

E:DataCompLibrarySDL2-2.0.3libx86

I also added the include files location in 'search directories' and that works fine.

But still when I add 'SDL2.lib' in linker settings and try to compile I get: cannot find -lSDL2.lib

View 3 Replies View Related

C++ :: Loop Through Indexes In Guess Array And Assign M Randomly

Jan 19, 2013

Just run a loop through each of the indexes in the guessarray and assign 'M' to them randomly.

View 2 Replies View Related

C++ :: How To Loop Through Files

May 18, 2014

I have a program below that calculates the average, sum, etc of the numbers in a file named "mynumberlist1.txt".

I want to create a loop whereby the program loops through several files; mynumberlist2.txt, mynumberlist3.txt, and calculates the statistics for all relevant files using the calculations below. How would I do this?

#include <iostream>
#include <cmath>
#include <math.h>

[Code].....

View 1 Replies View Related

C/C++ :: Writing Multiple Files In Nested Loop?

Jun 3, 2014

I would like to do something like this:

for (int i=0; i<5; i ++)
{
for (int j=0; j<5; j++)
{
//* CREATE A NEW FILE FOR WRITING * //
}
}

I don't know how to create a new file that doesn't get overwritten each time the loop runs.

View 13 Replies View Related

C++ :: Write Data Into Files In A For Loop - Debug Assertion Failed?

Apr 14, 2012

In my program I open two files and write data into each, and close them. this is done in a while loop.

int main() {
while() {
myFile = fopen("file1.txt","w");
myFile2 = fopen("file2.txt","w");
// write data into files using fprintf() in a for loop
fclose(myFile);
fclose(myFile2);
}
}

However, after some iterations the fopen() for myFile2 fails.

Debug assertion failed!
Program....
File ......srcfprintf.c
Line 55

Expression (str != NULL)

I have not been ableto locate the bug in the code that is causing the failure.

View 7 Replies View Related

C :: Program To Hide Files Behind Other Files Using Alternate Data Streams

Apr 5, 2013

I am writing a program to hide files behind other files using Alternate Data Streams in Windows NTFS file systems.

The program is as follows:

Code:

#include <stdio.h>
#include <stdlib.h>
int main(void){
char hostfile[75], hiddenfile[75], hiddenFileName[15] ;
printf("Enter the name(with extension) and path of the file whose behind you want to hide another file: ");
scanf("%75s", hostfile);

[Code]...

The complier is showing error as "Extra Perimeter in call to system" but I am not getting where?

View 4 Replies View Related

C++ :: Display Last 1000 Lines From Multiple Text Files (log Files)

Jan 16, 2014

I am writing a piece of code that requires me to display the last 1000 lines from a multiple text files (log files). FYI, I am running on Linux and using g++.

I have a log file from which - if it contains more than 1000 lines, I need to display the last 1000 lines. However, the log file could get rotated. So, in case where the current log file contains less than 1000 lines, I have to go to older log file and display the remaining. For e.g., if log got rotated and new log file contains 20 lines, I have to display the 980 lines from old log file + 20 from current log files.

What is the best way to do this? Even an outline algorithm will work.

View 6 Replies View Related

C++ :: Assign Value To Interval

Oct 2, 2014

This is my code , i should Assign value val to interval [keyBegin, keyEnd).

#include <assert.h>
#include <map>
#include <limits>

void assign( K const& keyBegin, K const& keyEnd, const V& val ) {

if(!(keyBegin<keyEnd))

[Code] .....

View 7 Replies View Related

C++ :: Assign Value Dynamically?

Jun 18, 2013

I have array of pointers and when i tried to assign values dynamically all array items have the same value which is last value.

char* list[];
int DynamicDemo(void)
{

[Code].....

View 2 Replies View Related

C++ :: How To Assign City To The List

Apr 21, 2013

I am having some difficulties knowing how to assign city to the list.

Code:

class DestinationList
{
private:
int num;
// number of objects in the list
Destination list[MAX_CITIES];
// array of destinations
public:

[Code]...

View 14 Replies View Related

C :: Assign A Pointer To A Function?

Jan 24, 2013

How can we assign a pointer to a function? const char* function_name(), here what exactly does the pointer point to?

View 4 Replies View Related

C :: How To Assign Value From A Function To Variable

May 26, 2013

Im starting with C. Like I said in the title, how do I assign the value from a function to a variable? I mean I have this function:

Code:

int EnteroAleatorio(){
rand();
return rand();
}

and I would like to assign the value of EnteroAleatorio to a variable in my main function, but when I try to do it and compile, I got the next error: non-lvalue in assignment

View 1 Replies View Related

C++ :: Why Assign A Pointer To Array

Jan 15, 2015

Why would you ever assign a pointer to an existing array?Take this link for example. URL....I understand that pointers use dynamic memory allocation so they are much more flexible then a built in array, but if you already have an existing array, don't you already have static memory allocation for that array? Why bother assigning a pointer? Regardless of the pointer, doesn't the program still allocate static memory to the array anyway?

View 3 Replies View Related

C/C++ :: How To Assign Text To A Textbox

Apr 24, 2015

I have a silverlight app that uses TextBox XAML controls.

In the c++ code-behind, IXRTextBoxPtr types are associated with these textboxes using "FindName" like this:

FindName(L"ColNum3", &m_pColNum3);

(where ColNum3 corresponds with the XAML CODE like this: )

Then, the code assigns the pointer like this:

std::wstring wsTransfer; // gets the wstring from imput
const WCHAR * wpszInput;
wpszInput = wsTransfer.c_str();
m_pColNum3->SetText(wpszInput);
but the display does not show the text data.

What am I missing? What steps am I missing to have this text modification display on the screen?

View 6 Replies View Related

C Sharp :: How To Assign String Value In C#

Dec 3, 2012

Below assignation? It is a bit confusing.

myString = ""myInteger"is";

View 1 Replies View Related

C++ :: How To Assign A Rectangle To Images

Apr 26, 2012

I am making a game Pong, and have been struggling with the collision aspect between the baal hitting off the paddle. I have created a Class, to draw a rectangle, to work with collision however I dont know how to assign the rectangle to the images of the ball and paddle.

#include "stdafx.h"
#include <iostream>
#include <time.h>
#include <vector>
#include <cmath>
#include "gwin.h"
const int NUMBEROFBALLS = 1;

[Code] .....

View 1 Replies View Related

C++ :: Vector Assign In Two Dimensions

Oct 29, 2013

If I have a one-dimensional array of length 10, vector<int> x, and I want to assign all the elements to value 5, then I can do the following:

Code:
vector<int> x(10);
x.assign(10, 5);

(I can also do this in x's constructor, but in my scenario I want to repeatedly assign x's elements in a loop, without having to construct a new vector in memory each time.)

If I now have a two-dimensional vector, vector<vector<int> > y, and I want to assign the first vector to length 20, the second vector to length 10, and each element in the second vector to value 5, then I can do the following:

Code:
vector<vector<int> > y(20, vector<int> (10));
for (int i = 0; i < 20; i++) {
y[i].assign(10, 5);
}

But is it possible to do this without the loop? Can I make the two-dimensional assignment in just one line, in the same way that the one-dimensional assignment was made?

Perhaps it would like something like the following, which is not correct but illustrates what I mean:

Code:
y.assign(20, assign(10, 5));

Another way of doing this would be the following:

Code:
y.assign(20, vector<int> (10, 5));

But wouldn't this cause the memory in the second array to be dynamically allocated each time? I don't want to do this - I want to keep the same memory, but just assign the elements to 5.

View 1 Replies View Related

C :: Assign Bit Widths Manually To Numbers?

May 13, 2013

I'm trying to learn how to assign bit widths manually to numbers. Here's my code below:

Code:
#include <stdio.h>
struct node {
unsigned long x : 53;

[Code].....

And I get the following complaint from the -Wall compilation flag, " warning: format '%lu' expects argument of type 'long unsigned int', but argument 2 has type 'long unsigned int:53' " which is talking about anna.z, to be specific.

How do I add field width to printf?

View 3 Replies View Related

C :: How To Assign String Hello To Structure Member

Feb 17, 2015

See the simple code below. The compiler gives message:

assigning to type "char[20]" from type "char *".

I've tried everything else that seems reasonable but none works. How can I assign string Hello to the structure member?

Code:
int main() {
struct strc1
{
char msg1[20];
char msg2[5];
}
talk;
talk.msg1 = "Hello";
}

View 5 Replies View Related

C :: Assign Pointer Of A String To Integer

Mar 22, 2014

I have this code:

Code:
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
[code]....

What I want is basically to assign to the *p the pointer of the string so that i could do the following printf(" print string %s",*p); so i dont know how to do that.

View 6 Replies View Related

C :: Assign Strings To Double Pointer

May 2, 2013

When I try to assign strings to a double pointer, it only prints out the last string when I try to print everything out, and then it segfaults.

Code:
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <assert.h>
main(){
char **test = calloc(3,sizeof(char));

[Code] .....

Am I assigning something the wrong way? Also, I am trying to avoid using array notation in order to practice, at least for the assigning of the strings.

View 11 Replies View Related

C :: Assign System Call To Variable

Feb 22, 2014

I have to ask system (linux) for a value and then assign it to the variable.

Example:

unsigned char date[] = system("date");

Of course this is wrong, but illustrated what is my goal.

How to achieve this effect ? I've heard about POSIX but how to include and use it.

View 10 Replies View Related

C :: Cannot Assign Struct Member Values

Feb 13, 2015

I'm a C beginner trying to assign struct member values to other struct members to create a list.

I've tried dot notation, pointer notation, strcpy, memcpy, memmove and normal assignment.

Nothing has worked.

cust_list.h

View 5 Replies View Related







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