Im programming client/server app that client provide the file name then the server send it to client then the client will save it ..this is part of code in client
Code:
char buffer[1024]; printf("FIle is being downloaded ... "); printf("%s ",buffer); }
[code],...
So i have 2 problems ::
1st one is when i write to file the file permission i cant define it with data type mode_t ,so the file does not open at all after creation...
2nd one is: the data in buffer is less than 1024 ,the data wrote to buffer but with garbage data . How to make the file read only the real data with garbage ??
I a want to write a code to convert a string into binary data for that i wrote a code its working perfectly but there is one problem , some of the binary data is written in 7bit and i want to convert it to 8 bit by adding 0 to the last.
#include <iostream> #include <fstream> #include <string> using namespace std;
I am having problems either writing data to a binary file or reading from the file. Through the process of elimination I am posting the code where the data is written to file to see if I can eliminate that as an option. I know the data is being processed correctly because, through the use of another function, I can view the data.
I also know that fwrite must be including some padding because the file size ends up being 576 bytes after it is written instead of 540 bytes (the size it would be if no padding is used). Here is my struct:
Code:
typedef struct { char teams[25]; float wins; float losses; float pct; int runsScored; int runsAgainst; } STATISTICS;
Code to write data(Double type e.g 12345.67891) in text file like pattern given below. Remember to put tab between each column.
----------------------------------------------------- Column1 Column2 Column3 Value 1 Value 2 Value 3 Value 4 Value 5 Value 6 Value 7 Value 8 Value 9 ----------------------------------------------------
I'm facing a problem regarding data entry in file.I'm making arrays which terminates when I press enter key but problem is that character at 0 index is not in file while rest of the indexes are there .. In other words,while writing on file my first character of any array got missed and did'nt present in the file ..
I'm trying to read a file that is in byte format then append it onto another file. I'm doing this with unsigned char variable types because they're always one byte. Since the format is simply using bytes, they don't care about the character representation. However, when I read the characters in then put them out again, the '/n' character is always preceded by the '/r' character. In hexadecimal this looks like 0D0A. I have no control of this, and it seems as if it's being done automatically by the ofstream.put() function.
So, is there a way to take away this appending of characters and simply writing the raw data to the file?
When you have to write data on a file in binary mode multiple times (without closing the file), is the put pointer left where you ended writing the last time, or do you have to use tellp() or seekp() again and again to make sure you write at the right place?
I would have the same question about the get pointer, does he stay in place after you're done reading something (without closing the file, of course), or do you have to set it back at the right place with seekg() ??
How would i write a functor for this code. The code is written to read data from a file and store in a multimap.
The data has numbered lines. E.g.: 1 This is a string 2 This is a string too
So the aim is to store each word in the line with the number and then to enter a word to search for the line numbers it appears on. I do not know how to go about and write a functor
#include<iostream> #include<sstream> #include<fstream> #include<cstdlib> #include<map> using namespace std; int main() { multimap<int, string>myMap;
I am using visual studio 2012.....in below code i m writing data in to a test.txt file but i dont know with which key file stop accepting char...i tried ctrl+z and ctrl+d but not working ....
I am looking at one of the functions of an exercise:
void escape(char * s, char * t) { int i, j; i = j = 0; while ( t[i] ) { /* Translate the special character, if we have one */ switch( t[i] ) {
[code]...
Notice the while loop evaluates the current value in t to true or false. When we hit the null terminator, does that get evaluated as 0 and hence evaluates as a falsy value so the while loop exits?
I am trying to make a project using arduino to control several power surces by time, i don't want to have an lcd, that would be easyer but i don't have enought space on my project, i want to set the time and the timing for the relays via Serial
Of curse i could set it using the serial monitor on the arduino ide, but i want to make a simple program to make the pc comunicate with the arduino and make it simpler to set the time and similar stuff. How to use one of my usb ports to print and read serial data?
I am trying to use myfile to create and write user data to a file [URL].
At the moment I only want to save as .txt so that I can open it to see that it wrote to file properly.
The main issue I get is that it says the file is not open when my program gets to the error checking at the very end, a few guides mentioned that if the file was not yet created a file with the specified name would be generated in the same folder as main on the hard drive. I did try creating the file as a notepad .txt file but it still read the error. Here is the snippet concerning the writing of the file:
it compiles fine with the rest of the program and everything runs smoothly, it just isn't writing to a file.I have included <string>, <iostream> and <fstream>.
Basically, I want to write an image to disk in parallel with an algorithm that is processing that same image. The code is really simple:
Code: string ProcessImage(System::Drawing::Bitmap ^bmp, System::String^ targetFile) { bmp->Save(targetFile); System::Drawing::Bitmap^ bmp8 = BitmapConvertPixelFormat(bmp, 8); //<-- a function I wrote which converts the 32bpp I am passed into an 8bpp one string results = Analyze(bmp8); //<--- takes a good bit of time return results; }
What would be the fastest way to do this? Any libraries with a code sample. I would prefer one that is within .NET or native C++ just to avoid having to link into many different libraries.
Note: V_hChildStd_OUT_Rd is a handle to the output of program A.
After running the program although bSuccess becomes TRUE, Buf array does not include the number (12.54) that I am expecting. If I do the same process without using the binary format it works fine and I can read the number. I know somethings wrong with the writing or reading of binary data but I do not know what it is.
I would like to extract and analyse the data but the data behind the NUL entry is not accessible for me maybe due to the fact that NUL normally marks the end of a line. Is there a method to remove the NUL entries in this text file?
How to read and write an arbitrary number of bits from/to a file stream.
For instance, how to repeatedly read 9 bits from a file, then change to 10 bits, then 11 bits, and so on?
Obviously one way is by doing a lot of bit shifting, and masking. But honestly, I'm too dumb to get it right. Then I thought about using std::bitset and std::vector<bool>.
When you login to my site my loginservice which is done by ajax and json make a session called context.Session["Name"]. With BreakPoints it shows that everything is good and the variables are in place. However when I use Session["Name"] it comes out as null.
I will add my code at the bottem not
using System; using System.Collections.Generic; using System.Linq;
I am writing a simple file/text parser to read a config file for some code I am working on. It's dead simple and not particularly smart but it should get the job done. The code reads a config file:
Here is where it gets wierd. You'll notice that there is an unused variable (filepath) in the config struct. This variable is not referenced or used anywhere in the code, ever. Yet if I comment out the declaration of char filepath[1024], the code segfaults partway through the read_config() function.
My best guess is that there is a buffer overflow elsewhere and it just so happens that the memory allocated for filepath happened to be there to catch it up until now, but I can't work out where it might be happening. With the declaration commented out, the read_config() function gets as far as reading the "padding" variable before it crashes. Yet when the declaration is there, then all the variabled are read correctly and everything seems to work.
One of my class assignments is to create a program that receive a .txt file containing a students name and their grades as follows: John K. 99, 87, 57, 89, 90, 95 Amanda B. Jones 100, 88, 76, 99, 86, 92 etc.. The number of students is unknown until run time. You have to take those grades and average them weighing the first (4) at 10% a piece and the next (2) at 15% each and the final at 30%. Then return an output file with the students name and their letter grade A,B,C,D,F based on their computed score. In addition, on screen it needs to display the average scores for each Q1, Q2, etc. as well as the minimum and maximum for each test on the screen. I am having a hard time in assigning the scores to a variable so that they can then be computed as an average and then used to determine a letter grade. I have begun to write the code and am a bit stuck..here's what I have so far:
Code: // // main.c // Final Exam //
[Code].....
The problem I'm having now is how to go about passing the grades to the function computeGrade and then compute the average and return that to the function.
I'm writing a program using Huffman algorithm to compress text file. I have tested my program by just printing the printing ASCII character to file and it worked fine. However, now I have to implement using bits and my program doesn't work. It seems like I'm not reading or writing the right bits. Here is the result of my testing:In the input file I put abc the input file to compress it. Then I uncompress it the out out is aaa. Below is a snippet of how I read and write bits
Code: class BitInput { istream& in; // the istream to delegate to char buf; // the buffer of bits int nbits; public:
I have a question about an issue I am having on my final project. Within my ItemEntry.cs form, I am trying to get the application to append the already existing .txt file, rather than prompt the user to replace it. I can't seem to get the StreamWriter and FileStream to allow the user to write to the file.
Code: using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq;