C++ :: Enter Manually A Path?
Jan 26, 2015about putting manually a path in my code.
This is what my code should looks like
#include <iostream>
#include <fstream>
#include <vector>
[Code]....
about putting manually a path in my code.
This is what my code should looks like
#include <iostream>
#include <fstream>
#include <vector>
[Code]....
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?
I want to display a bmp file of resolution 600*420 (using c compiler like code block ) by manual loading. I tried to display the image by loading the pixel value. but this method has a limitation that it take up pixel value of image upto 64kb size.
So now i am trying to load it manually. What are the steps that i has to follow, what are the header files that i has to use ?
My system specification are windows xp professional , intel pentium 4 cpu. I don't know where to start ,does this method has any limitaton ,...etc ........
I'm a C beginner. I have questions, let say if I have a structure of message containing of Id, Length, and 3 bytes of data, and I want to manually saved in individual bits of data, how can I do that? I confused on how to use typedef struct and union. Below is the sample code:
typedef struct {
uint8_t Id;
uint8_t Length;
uint8_t DataField[3];
}AA;
[Code] .....
By the way, the DataField is declared as above. It's not necessary for a data to be 24 bits. It can be bit 0 - bit 8, it can be bit 10 - bit 15 and so on. So, for each case, I want to ignore the other bits.
how to manually control the temperature of High Power Leds using PID controller. I have two GUIs,one reads the temperature from the Led while the second is used to ON/OFF the Leds and at the same time controls the Led brightness using slider control.The GUI that reads the temperature has a PID controller application on it.The output from this controller is what i want to use to increase or decrease the Led brightness which invariable changes the Led temperature.How to go about using this PID controller to control the Led brightness is what i have not been able to grasp well.The slider on the GUI is scaled from 0% to 100%.My thinking is that the output from the controller should be in percentage which will make me to adjust the slider accordingly.My question is that will this type of arrangment produce an output that will efficiently control the Led brightness. how to accomplish that. Attached to this post is a modified code of a tutorial on PID controller which i found on the net. a tutorial on how to develop a graph. i wish to display the Setpoint,Process value and the output value on a graph.
View 2 Replies View RelatedI got a little question about getting the data path of my c program. I heard something like it's already given in the "int main(int argc, char **argv)". But with witch function can I get it?
For example: The program is called Pathfinder and the path is 'D:Path1Path2Pathfinder.exe'.
I have a string like this
const char *filename = "C:/Qt/progetti/worlds/fasr.world";
then I have a string like this
char *pathdir = "C:/Qt/progetti/worlds";
I would get this string: "worlds/fasr.world" how should I do ?
I wanted to make my program read the file "input.txt". I did it successfully, but now I want to get the full path of the file "input.txt". Is there any way to do it?
My output should be :
FILE *file;
std::string fullFileName;
file = fopen("input.txt", "rb");
if(file != NULL)
{
// getfullfilename(file, fullFileName);
// std::cout << fullFileName.c_str() << std::endl;
}
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.
The following code writes to a file on either local disk to a remote disk (commented out code) on Windows 7 platform.
Code:
#include <iostream>
#include <fstream>
using namespace std;
int main () {
ofstream outfile;
[Code].....
The documentation does not specify what is a valid filename (path and filename). For example, will the "\server emp" path work on all operating systems to access a samba share? Does the constructor accept forward and backward slashes as folder separator on all operating systems?
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
How to get a full path of a directory only using a text file name? (Btw i am using visual studio not windows)...
View 9 Replies View RelatedI need to open a text file game_scores.txt and i can not figure out a way to.
#include <iostream>
#include <string>
#include <fstream>
using namespace std;
int main() {
[Code] ....
the code is used to read the text and take the first 4 pieces of info but i do not know how to do it. i have already created the text file and moved it into the source. i am using visual studios 2012. In 2010 the text file would show a relative path, it doesn't in 2012
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?
I need to append file path for some particular program. But the problem is when I append it like below, it gets error whether filepath seems to be C:/Users/My/Desktop/C++/1.txt
int i=1;
stringstream str;
str<<"C:/Users/My/Desktop/C++/"<<i<<".txt";
string filepath=str.str();
cout<<filepath;
ifstream ipf(filepath);
if(ipf)
{ do some thing...}
But if it was like this no error, program work as desired.
int i=1;
stringstream str;
str<<"C:/Users/My/Desktop/C++/"<<i<<".txt";
string filepath=str.str();
cout<<filepath;
ifstream ipf("C:/Users/My/Desktop/C++/1.txt");
if(ipf)
{ do some thing...}
I want to include turboc.h file for some project
where do i have to add this file for mac xcode?
FILE* pFile = fopen ("./myfile.txt","w+");
Is there a way to change what a relative path is referencing after runtime has started?
My specific issue is that I have several existing 100,000+ LOC lua projects. I am building a new back-end in C/C++ for this by wrapping a Lua C library. The lua scripts use io.open("./path/relative/to/project/file") which translates to fopen(...) in C. The project file which this is relative to is opened by the user after the application has started.
I see two solutions, neither are particularly good:
1) Change every io.open() function in every project to be relative to a static location. I lose all flexibility if I do this.
2) Modify the Lua library to prepend a custom path to opened files. Modifying 3rd party libraries suck because you can't update the library without tracking patches.
3?) Ask cplusplus forum if there is a way to change the relative directory.
In my C++ program, lets call it menu.exe, I want the user to be able to run a specific program when selecting a specific menu, let's call this program cios.exe.
As the users of my program can have the cios.exe installed in any folder location, I need a way to first locate where the cios.exe is located and then start it with ShellExecute. My problem is : How do I find the path to where cios.exe is located in anyones PC as it can be installed it any folder location.
I have my application database in the AppDataRoaming folder. I'm trying to create a connection string for Telerik reporting, up until now I've had a connection string in a settings class that is put together like this:
The path is:
data source=C:UsersSynlightAppDataRoamingAppNamedataAppDB.sqlite
I've tried files paths like this:
%AppData%RoamingAppDatadataAppDB.sqlite
and
Server.MapPath(@"~App_DataRoamingAppDatadataAppDB.sqlite
(those are not the real directory names, of course). How do I create a connection string that will work on target machines?
I am new to Path Finding so I just know BFS, DFS, Djisktra, and Basic A*
I've searched for a few multi agent pathfind paper here and there. But I can't seem to understand them..
I am path finding in a grid map, 4 ways neighbor movement
My map isn't so big it's 300 x 300 up to 400 x 400
Most of the map is open space, I would say that at worst case 4/5 of the map is open space.
And there is probably around 100 agents.
I've tried running BFS 100 times and it takes around 200ms on average
Changing BFS to A* which I am thinking right now will definitely cost lesser time
But are there better ways in doing this ? and also Does running Single Agent A* multiple times doesn't cause problem for other agent ? perhaps causes deadlocks ? ( Considering that the path that have been determine for agents before the current searched is considered blocked )
how to get source path of selected file.
for example :
selected image in E:/
E:ewfolderillustration.jpg
application - asp.net(C#)
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);
I have a comboBox that I created in XAML using using binding and I'm unable to get the selection. I've tried everything I could think of or find on, but no luck.
Here's the relevant XAML and C# code for the comboBox:
<ComboBox Name="projSelected" Selectionchanged="projSelected_Selectionchanged" HorizontalAlignment="Left" Margin="424,27,0,0" VerticalAlignment="Top" Width="199" DisplayMemberPath="proj"/>
projSelected.ItemsSource = DAL.projectList;
Then here is where I try to check the selected value:
private void projSelected_Selectionchanged(object sender, SelectionchangedEventArgs e) {
projectDataList.ItemsSource = null;
projectDataList.Items.Clear();
[Code] ....
And here is my output in the MessageBox that I'm using to test the code:
Quote
project=Website selected=employeeProjects.project
I was asked to find the longest path in a graph. I was thinking about using Dijsktra's algorithm after multiplying all the weights with -1 and run the program in normal way and find the shortest path. And then I'll multiply with -1 again and get the longest path. I think this should give me the longest path, do you think it would work? And also, I'm dealing with considerably big data, such as 1.000.000 nodes and many more edges. etc. and I have a time limit of 2 seconds and memory limit of 128mb. Any other data structure instead of Adjacency Matrix? Because I'm pretty sure it will exceed the limits.
View 2 Replies View RelatedSuppose there are two cpp programs and we want the user to put the complete path of the first cpp file into second cpp file while it(second file) is running and compile and show the output there, so how can this be done?
View 3 Replies View Relatedi want to create/open any file present in any location in my computer. How do I assign a path in C++ syntax?
View 1 Replies View Related