I wrote a program to write text contents to file stream through fputs, the file stream address was changed in the middle of writing text content to the stream (11% text content have been put into the file stream), that cause the file stream pointer can be evaluated problem and raise exception on stream validation code in fputs library function, my question is what things could go wrong to make file stream pointer changed its address to something else or a NULL pointer if the file stream have not been flushed and closed.
I am trying to create "dummy" drivers for testing purposes of another program of mine.
I want to be able to Call DeviceIoControl and pass a string in as the buffer and then receive that string in the driver, change it and return it. But right now I am not able to receive the string, when i get the buffer and print it out it is garbage. Where am I going wrong?
I sent 1preample and 4bytes in transmitting side , preample contains only 1 and 0 with 4milliseconds delay, each byte contains 8bits with 2milliseconds delay , if a bit contains 1 it will send 1millisecond high and 1millisecond low signal ,and if a bit contains 0 it will send 2millisecond continuous delay, I have a problem at receiving side how to capture and store the preample and 4byte values in a buffer , i am using ARM processor it will update every 5microsecond ..
I have a problem with my C#. Trying to create the airstrip with planes heading out of the hangars and on to the road to the airstrip. Each Hangar pannel is connected with closes road to them. What i am stuck with right now is connecting the roads together so each one of them will see if the next road is free and if it is it will send the plane (colorder square for now) to it and then proceed to the next one when finaly they will line up for the final panel(airstrip) and take off.So far they are just going down the each road they are assigned with semaphore and thread.
using System; using System.Windows.Forms; using System.Threading; using System.ComponentModel; using System.Collections; using System.Data; using System.Drawing;
[Code] ....
Connecting the "p2" with "p5" so the graphics from "p1" the square will travel through P2 and P5 this would be great and will allow me to procede with my studies.
Also i do realise that this might not be the best ways of using concurrent Csharp and not the up to date one but this is what i have been assigned with and do not have any other options unfortunately.
How i understand this is that i need to have 3 buffers and 3 semaphores for each panel. But i do not know how to add those to each one of them and then connect it with the next one as if i try and add them it either puts a cross in the design view over that panel or says that there is limited options for this statement.
This is the way that i want to do it unfortunately it must be so. The most flexible this can be is by adding an array for semaphores and buffer ( do not know how to do that either).
Assuming I have a list of pointers to a generic type T:
#include <vector> //... list<T*> myList;
Now assuming I want to go on the list, and if T's type is matched to the type I'm looking for, then cast it to this type and do something. List shown here:
When using an iterator with a std container (list / vector etc) sometimes it's possible to modify the container (e.g. delete an item) yet still carry on using the iterator - whereas in other cases, modifying the container immediately invalidates any open iterators on it. Is there an easy way to know which containers fall into which category? (or does it vary from one compiler to another?)
I am working on very large code. I got a segmentation fault when trying to use one cpp file and tried to locate the error using Valgrind
Since the code is very large, I will only post a short portion of it below. I think the problem may come because triann is a vector defined in the header class, so triann[tri] is causing problems?
void ADe::aNe(int v, set<int> &nei) { for(set<int>::iterator iter = vert2tri[v].begin(); iter != vert2tri[v].end(); iter++) {
I'm working on writing some classes around a ROM hardware addon card. The classes expose the data on the ROM as a container with iterators, much like a vector or a list.
The classes don't have any data themselves, since all the data is on the ROM.
I'm having some dillemma's as to how to approach/implement the classes. If you were to write somethign like this... Or were using something like this written by someone else.... How would you expect this to be done ?
1) Make all the member functions static, make a private constructor to prevent making instances. This works, but may look a bit weird...
Code: for (auto it = RomTable::begin(); it != RomTable::end(); ++it)
2) expect users to make a (dummy) instance, then use it as a regular container. this might be a bit counter intuitive since the class has no datamembers.
3) create a single instance, expect users to use that everywhere. make the constructor inaccessible. Some C++ 'purists' might perceive this as global data and thus not a good solution ?
Additionally. Do I need to provide both a const_iterator and an iterator ? There's nothing to be modified, so I'm guessing an iterator isn't needed (?) Or will some STL stuff not work without an iterator ? I'm obviously not fussed about the STL functions that make changes to the container to not work (like sort, fill, swap...)
So i made an STL compatible container.And to make this work I had to make my own iterator (derived from std::iterator).
What is the portable (if any) and "well behaved" thing to do in case of usage anomalies.such as iterating an iterator too far, or passing an invalid index to a operator[]
Looking at how VC++ does things in something like std::array or std::vector.
Code:
iterator_type& operator+=(difference_type offset) {// increment by integer #if _ITERATOR_DEBUG_LEVEL == 2 if (size < index + offset) {// report error
[Code] .....
lots of names starting with underscores, so it's implementation specific. Is there even a "well behaved" thing to do ? Or is any such work always going to be compiler specific?
I have a 'Graph' class, which has derived classes for Adjacency Matrix and Adjacency List representations.
How do I provide iterators for traversing vertices and edges, when the iterator classes would have different implementations for the different derived classes ?
The following way is the only one I can think of, but seems quite cumbersome.
Or is there a pattern for doing this that I'm not aware of ? Would composition be a better idea here compared to polymorphism ? I mean, I can think like..a Graph can 'have' several representation 'objects' within it.
All the involved classes are templates,not sure if that makes the situation different.
I get this error when i try to run this code for an inventory in debug mode in VS. But for some reason it works just fine in release mode.
void Push_Back_Item(Item *item){ for(int y = 0; y < InvSizeY; y ++) for(int x = 0; x < InvSizeX; x ++){ auto Iter = ItemList.find(std::make_pair(x,y)); if(Iter != ItemList.end()){ item->SetDead(); // ERROR } } }
This isnt the full code though but it still gives me the same error.
The only thing "item->SetDead()" does is to set a bool to true.
This is the map i get the iterator from std::map<std::pair<int,int>,Item*> ItemList;
This have been bugging me for quite some time now.
Why does my loop loops 3 times when i have only 2 line of data in my file? From the cout << s.size , when i run it will show 1,2,3.
Information in txt file Code: local john 10/2/1990 international tom 2/5/2000 output Code: local john 10/2/1990 international tom 2/5/2000 international tom 2/5/2000 Code: ifstream in(filename);
I'm having some trouble with copying one I/O stream into another. I've put the first one into an array but I cannot get my second prompt to copy the .txt file the first prompt sees and outputs to the console. When I try and grab the info from the .txt file my first prompt sees I only see blank space in my .txt file.
#include <iostream> using std::cout; using std::cin; using std::endl; #include <fstream> using std::ifstream; using std::ofstream;
#include<fstream.h> #include<conio.h> #include<string> class CLS { public : string name;
[code]....
I have used the above code to write the class instanc to a file "Text.txt"...But it seems that "f.write((char*)&c, sizeof(CLS));" is not working properly with string. The data can easily be written using stream object!
#include<fstream.h> #include<conio.h> #include<string> class CLS { public : string name;
[code]....
When I tried to read the data on the file...., it gave an error "Thread stopped...violation.."
I am currently trying to read in a file that takes in the input in the following form.
Code: HANK>25 BOB>31 AL>54 BILL>41 ABE>63 JEFF>50
I have tried the following solution:
Code: #include<ifstream> #include<iostream> using namespace std; struct node { string name; int age; ); int main () {
[code]....
The problem is a.name, it's extracting the entire string before the space character causing p.age to contain "BOB" and so on. I've tried using p.get(p.name, sizeof(p.name), '-') with '-' as the delimiter and p.getline() using a character array instead of a string. How would it be possible to only copy the string into a.name before the '>' character?
Let us assume I have a program that takes the name of the output file from the command line. Now let us assume that a decided not to give any output file location but wanted my program to to print my strings/ints ... directly to stdout. how would one do this using file streams? Using file pointers and c that is pretty straight forward but how would i achieve this in c++.
I'm supposed to add two new functions to an existing class that I've written early on: readData(ifstream&)and writeData(ofstream&).
The parameters of the program are: -Create three employee objects as shown, -Create an ofstream object and open a file. Choose any name for the file that you want. Do not ask the user for the file name. Pass just the file name as the parameter (no path) so that your program assumes the file to be in the same folder as your executable file. -Send messages to each of the three Employee objects to write themselves out to the file. -Close the file. ...
If I get writeData(ofstream&) function bit to work! for brevity I've cut all the functions of the class that arent necessary. Here's what I have so far:
Employee.h #pragma once #include<string> using namespace std;
[Code] ....
So I've tried a bunch of different ways to get my objects into the ofstream object to write them to the file, but I'm supposed to use the two new functions somehow...but I'm way lost.
#include <iostream> #include <string> #include <istream> #include <sstream> using namespace std; int main() { string groups[3] = {};
[Code] ....
It outputs jibberish. I can do what I need to do but I would need to declare more variables and write more cout's, isn't there a way to add these elements to a stringstream or streambuffer? My goal is to write this program and make it as comprehensive as possible but also with very few lines.