I am trying to create a program that will read data from a text file into a string. Afterwards I need to sort the data in ascending order and print it. So far my program reads the data but I'm not sure how to go about indexing the array.
I have having trouble looping through the list in the update section to update each object in the rectangleList. I am not sure how to format it because it is only drawing one and it does not move across the screen. I thought this section of code would work and loop through each object and make each one move but it does not.
for (int i = 0; i < rectangleList.Count; i++) { enemyPosition = new Rectangle(rectangleList[i].X + 2, rectangleList[i].Y ,enemyPosition.Width,enemyPosition.Height); } List<Rectangle> rectangleList; protected override void Initialize() { rectangleList = new List<Rectangle>();
For the past couple of weeks I have been working on a template to hold two-dimensional arrays. Right now I am puzzling over an indexing question.
There are many places in the template where I would like to use initializer_lists to refer to user-specified row and column ranges, particularly in member function arguments. A typical example would be a member function whose declaration would be along the lines of:
Code: Array<Type>::some_function(std::initializer_list<int> columns, std::initializer_list<int> rows); which could get called via
Code: arrayInstance.some_function({3:4}, {5:8});
It would be really nice to be able to use Matlab-style indexing to specify the last column, or the last row, in the Array object -- along the lines of
Code: arrayInstance.some_function({3:4}, {5:END}); where END takes the value -1, and can be defined in Array, or somewhere else.
The way I have tackled this so far was to write myself an Indices PODS class with two elements to hold start and finish values, and a constructor-from-initializer_list that looks something like this:
Code: Indices::Indices(std::initializer_list<int> range, int replace_value) { int const *it = range.begin();
So the elements of "range" give the values of Indices::start and Indices::finish -- but if either of them are entered as END by the user, they will be replaced by replace_value. (The default value of replace_value is END, so Indices::start and Indices::finish will never change if it is omitted.)
I also defined an Indices::endset(int) function to do the same thing for existing Indices objects:
Code: Indices::endset(int replace_value) { if (start == END) start = replace_value; if (finish == END) finish = replace_value; } Using Indices::endset, you can code up Array::some_function by modifying the above signature to something like
Code: Array<Type>::some_function(Indices columns, Indices rows) { columns.endset(this->M); rows.endset(this->N); ... }
This does work, and I've been able to use it in practice. However, it is klutzy. What I would really like to be able to do is have the Indices constructor handle value-replacements in "columns" and "rows", instead of needing to put calls to Indices::endset in every single Array<Type> member function that uses this approach.
The basic problem is that, when Array<Type>::some_function is called, there is no easy way of inserting Array<Type>::M and Array<Type>::N into the optional argument of the Indices constructor when "columns" and "rows" are being built.
The Indices class needs somehow to get access to these, and know which one is being used, M or N. So it needs to have some sort of deeper connection to Array<Type>, but I don't know what that connection should be.
I've spent some time trying to performance test various methods of loading / accessing a file, either into memory or through a memory mapped file, but I am having some trouble.
FILE * pFile; std::ifstream ifs; MapViewOfFile
I'm have trouble because Windows appears to cache the file, so I am getting very mixed results. Sometimes a huge file (100's MB's) will load quickly, other times almost instantly.
How to stop Windows from doing whatever it's doing, so I can see the real time taken to load/access a file from disk?
My below code is createing databases(database here is a kd tree) and indexing one image per database. I have two classes LastDatabaseTndexingPolicy and another forwardingDatabaseaccessor.cpp .
I am calling the GetDatabaseToAccess() function from forwardingDatabaseAccessor.cpp class .GetDatabaseToAccess() function is present in LastDatabaseTndexingPolicy class and it returns the database created as a pointer and using that database pointer we call another function which actually indexes the image to the database .
Now my issue is i am not able to have multiple threads act on the following functions as DatabaseAccessor_ptr db which is in the following file is coupled with two functions and however i put locks in the LastDatabaseTndexingPolicy file as below i end up getting synchronization issue ..........
Hence now i am using a single lock in forwardingDatabaseAccessor.cpp and serializing the code,. How can i change my design to parallelize this code .........
In ForwardingDatabaseAccessor.cpp we are calling function from LastDatabaseTndexingPolicy as shown below:-
DatabaseAccessor_ptr db is something which needs to be synchroinized. I tried createing 256 databases with one image each and when i run this code i ended up creating 175 databses and though i was restricting in code with locks that every database has only one image i ended up having two images in single database ..... ideally i had to get only one image per database but i got two images in few of them hence instead of 256 database this code created 175 or so databases.
How do I read a .pdf file using C++? When I try to open it using myfile.open ("example.pdf"); but all I see is some Crazy Symbols. Is there any way to open ?
I am building a program that will read from a particular web page. I have written it so that it will parse the page correctly, but I can only do it for a downloaded page right now. I would like for it to work simply with the URL.
I have seen things about "screen scraping", though I don't quite understand what it does - I think it's more for just parsing it, which I can already do.
If it is possible to automatically download that file, that is fine as well.
If it matters at all, the pages I am reading from are stories on Fanfiction.net.
If I am reading data from a .txt file with a person's last name and first name (e.g. Miller Andrew), How do I output the same data with the first name followed by the last ?(e.g. Andrew Miller) Do I use the ignore function?
I want to know how to read a .pgm file from my hdd and store it in a 2d array so i can perform some action on the array later on. This is ny first time working with an imqge in c so i know nothing about it. .
So I'm trying to reformat a paragraph where the first letter of each sentence is capitalized and the rest are lower case. This is my function thus far. I'm trying to read for the end marks . ! and ? and have it so that once the are encountered the next word is capitalized. I used ispunct initially but it read for things like ,'s as well.
int PunctCount(string Text) //Counts the end marks. { int Total = 0; for (int i = 0; i < Text.length(); i++) if (Text == '.' || Text == '?' || Text == '!') Total++; return Total; }
Right now I get error: no match for âoperator==â in âText == '!'â
I have been given a task to make a c++ program that promptsd the user to enter a mp3 file name, read the ID3v1.1 tag and displays it. It then should prompt the user to to decide if they want to edit the comments section of it, then if they edit the section, it should re-print the updated ID3 tag. The list of genres are in a cstring that is as follows.
I'm absolutely new to C#. I got a code to edit so it can read data from website.
This is the website: [URL] ....
And I would like to read the data from the table from last row 'world' from 1980 to 2013. I have also went through the html to find a tag and i think its this one :
Where i should insert the tag in this code and what to do to run it properly in unity?
and this is the code I must use:
using UnityEngine; using System.Collections; using System.Xml; public class getWEB : MonoBehaviour { public string data1 = " "; //Light public string data2 = " "; //Humidity
The actual code is a bit longer since it offers you to input the size and then it draws the pic. Now that wasn't so hard and I've done that but now I wanted to implement the "MessageBox" func for output.
I managed to write the cube in file cube.txt but when I'm reading from it 1 char at a time since I need to output as char array it avoids all spaces and new lines and just puts all symbols in the same row.
I didn't have that issue with C and I've found on stackoverlow a solution using strings & getline but I need it to be in "char" form.
How to actually read spaces and newlines? This is my current code for reading from file:
Code: ifstream di("kocka.txt", ios_base::in); char c[5000]; int br=0; while( di >> c[br]) { br++; } MessageBox(NULL, c, "Kocka", MB_ICONHAND); di.close(); P.S kocka = cube (in croatian )
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 am aiming to read an integer from stdin(pointed to the uart) and echo it with the uart interrupt service routine. there is a simple retarget file along with the main code shown below. So far i can read chars (char x[32] but i am struggling with int.
I have gathered that i need to use the scanf function to read an int from the pointer defined in fgets.
My output is giving me weird values, i enter 8 and ill get a random 3 digits back. I have a feeling its a problem with the input buffer.
It appears that when you enter command line arguments or use fgets() to input a string you can assign that string to another string variable using the assignment operator. But when you read from a file, you can't do that, you get a segfault. It seems the only way to get around that is to malloc the string and use the strcpy function.
Code: #include <stdio.h> struct person { char *names[2]; }; void readFile(struct person p){ FILE *file = fopen("names", "r");