I'm trying to write a simple program that extract the FAT information from a FAT32 virtual Hard Disk.I have the following structures regarding the FAT format:
Code:
//BOOT RECORD
typedef struct NF_BOOT_RECORD
{
unsigned char BS_jumpBoot[3]; //EB 58 90 = JUMP 58 NOP (Jumps to boot code). Also E9 is acceptable.
unsigned char BS_OEMName[8]; //Either MSWIN4.1 or mkdosfs
unsigned short BS_BytesPerSec; //Little endian. The size of a sector. 128,256,512,1024...
unsigned char BS_SecPerClus; //The number of sectors per cluster (1 CLUSTER = BPS*SPC BYTES)
unsigned short BS_RsvdSecCnt; //The boot sectors (this) are included. That makes at least 1.
}
[code]...
Everything seems to work fine. Mostly. The only problem, is that the program gives me the following output:BS_NumFATs shouldn't be 0. In fact, I've checked inside the structure memory, and the information seems correct. BS_NumFATs is 0x02, not 0x00 (It's the byte at offset 0x10, starting at 0x00).
I've checked the order of the structure fields, and their types, comparing them to the FAT specification given by Microsoft (File fatgen103.pdf), and it seems fine, unless I'm missing something. So I don't know why it gives 0 instead of 2, if I'm missing something.It's a Win32 program compiled with GCC version 4.4.0
If we have to arrange large array structure, and we should also have to set a field which is the 'index' of elements in the structure array as:
typedef struct { int index; char [MENU_ELEMENTS_CHAR_MAX]; int value; boolean enable; } stc_MenuEntry; const stc_MenuEntry GlobMenu[] =
[Code] ....
Suppose we have a lot of row like those written before: also many structured array , and we should mantain: inserting and deleting elements, without having to worry about index error insertion, what kind of preprocess should we choose to best perform the automatic field writing? Obviously we could set properly any array field as:
Just to make the task easier, maybe to allow a 'program filter' to find and subtitute the field as required.
We should also put theese menu variable in RAM, and perform the field init, setting the index at run time, but if we want to save RAM (const attribute chosen) we must find a solution.
I thought about UNIX/LINUX OS filter like sed and awk which would maybe perform the task, before giving the source file to the building process, but I'm working on Windows environment and I don't know the appropriate tool to do this kind of work.
class DataBase { // Change the connection path here to your own version of the database public SqlConnection con = new SqlConnection(@"Data Source=(LocalDB)v11.0;AttachDbFilename=|DataDirectory|UberDatabase.mdf;Integrated Security=True;"); public DataBase() { } }
And in the same namespace as this class I have a form that calls it like so:
DataBase dBase = new DataBase(); SqlCommand trythis = new SqlCommand("Register", dBase.con);
However, I'm getting the field initializer error on dBase.con. I'm not sure why, but when I call the database from another file (program.cs) it works fine this way.
My program does compile and counts the number of lines of code, which is LOC: 20. My issue this, according to my code instruction it should not count comments (//) and also shouldn't count blank lines of code. Unfortunately my code is counting // and white space.
What seems to be working is #, all three includes are not being counted. That’s a good sign. I’m using the same technique not to count #. Why isn't working for comments and blank lines? I’m pretty sure that my logic is correct. I think my problem is maybe syntax.
#include <iostream> #include <fstream> #include <string> using namespace std; int main() { //read my file
I'm making some progress. My program does compile and output the number of line per code, but it shouldn't count comments and blank lines. I tried using (s.substr(0,2) == "//") as suggested but it didn't work.
This is my improved code:
Code: #include <iostream> #include <fstream> #include <string> using namespace std; const int A = 3; int main() { string s;
I wrote a script that generates n random pixel positions and draws them to the screen. Works well. Now i tried to rotate them. Rotating does work too. But it does not work as i planned it.
paramters 'angle' and 'timestep' work somehow, but not as they should do. the function 'move' is supposed to rotate the pixelfield 'angle' degrees in a given direction, addicted to the 'timestep' parameter. 'timestep' is needed time for drawing in one single game loop.
rotation point is the middle of the screen. when i set angle to 10 it should rotate 10 degrees / second. Instead it's rotating very very fast and all stars are moving nearer to the center of the screen, so after x rounds there is just 1 pixel left in the middle of the screen. there is a kind of gravition.I'm working with SDL2. What I did find out:
FPS is <= 60, 'cause of the 'SDL_RENDERER_PRESENTVSYNC' flag. When i skip that flag, for any reason the 'gravition' would take more time. FPS is <= 1400 then, 'though i got a natural game loop (i hope):
I need writing a program in c++ that will get the input of 50 different users for the following the fields (surname, other names, sex, status, date of birth) and after entering the data for these 50 users, it will then output only the list of all FEMALE users who were registered...
#include <iostream> #include <string> using namespace std; int main () { string surname, other_names1, other_names2, status, sex, dob;
[Code] ....
I don't really know what to do next - all my attempts have not really given me the result I want.
is there way that I go like: cout << c1; not overloading << operator; and it shows me a value of c1.x? just wanna replace c1 with that value; I need sth similar to indexer from c#.
I have a dynamic storage class based on a vector. The elements of this class shall be addressable via a string.
I have something like the following:
StorageClass* test = new StorageClass(); while(notEnd) { test->setValue("name3", 3); test->setValue("name2", 4);
[Code] ....
The Storage class is implement with a vector having to attributes per entry, the first one is name the second one is value. If the setValue function is called, Igo through the whole vector to find the correct item via the name and than i set the new value.
At the end of the loop i want to write out the data into a comma separated value file (*.csv). This shall be done generic by the writeLineToFile() function of the StorageClass.
As a want the columns in csv file to be sorted in a specific way a thought about a preInitalisation routine at the beginning of the program which builds a the vector with all possible entries as something like this in order to define a specific output order.
I now have 2 places in the code where i write down the "fieldnames".
I was wondering if there is a possibility to check if the fields called by the setValue function were first aranged in the vector by the assigned() function before or bettwer while compiling the programm.
I thought about MAKROS with #define XYZ and #ifndef XYZ #error to do though, but currently i reached a dead end and find no solution for my problem.
I am building a template for CodeBlocks, which pre-write some includes, the main skull and a header.
This header looks like that : /** * @Author Me * @Description Brief description * @Date ?? */
I would like to put the current Date, just after the line @Date, is-it possible ? And if yes, it-is possible to put a field @FileName which copy the filename into the comment ?
I need to use an instance of an object in a header file. The object requires a lot of pre-computation to be created.
I want to assign it to a "static const *NAMEobject*" field in the .h file, once it has been created. I assume that it is better to create it in another file and somehow pass it into the .h file.
I am experiencing some errors with my first c++ program. im getting some compilation errors that i cannot figure out.
In file included from w2.cpp:7: Fraction.h:17: error: variable or field 'enter' declared void Fraction.h:17: error: expected primary-expression before 'struct' Fraction.h:18: error: variable or field 'display' declared void and so on ..........
class T { enum E { } struct S { } interface I { } delegate void D(); class C { } }
[code]....
All of the above are possible except the constant field of a type that is a struct. I can see why the non-string reference types would default to the only literal expression they can represent - null - and if I'm not mistaken the default value of a struct is an instance of the struct with all its fields set to their default value, but why is it that a const struct field is not possible? is there a reason why or is it just the way c# was written? oh and by the way, what's the idea of allowing enum types to have a default constructor?
I'm creating a payroll program and here is my code
Code:
#include <stdio.h> #include <stdlib.h> #include <string.h> #define REPORTHEADING1 " Employee Pay Hours Gross Tax Net " #define REPORTHEADING2 " Name Rate Worked Pay Due Pay }
[code]....
The errors I get are: variable or field PrintSummaryReport declared void in function voidPrintSummaryReport... cannot convert FILE to const car for argument to int printf(const char*...) which is for the following lines
I need a static hash table to keep track of all objects of a particular type that are instantiated in a Qt application but I have never used a template class as a static member object before and I can't seem to figure out how to initialize it. QHash is the hash table class that follows the template convetion:
template<class key, class data>
QString is probably self explanatory.
Example Header:
class MyClass { ... private: static QHash<QString, MyClass*> instanceTable; }
Here is my source that doesn't compile.
Example Source
#include header.h // using default constructor for table... QHash<QString key, MyClass* instance> MyClass::instanceTable(); // gives Error below. // Error in above line is "Declaration is incompatible with QHash<QString, Myclass*>"
I have tried doing it a number of different ways and none of them work. How do you initialize a static template object?
In a numerically intensive code, I have a Cartesian vector class Vector3d which has the normal operator overloading and basic functions such as dot product, magnitude, etc. For simplicity, assume that it is not a templated class and its components are of type double.
I frequently need large 1-d arrays (e.g. stl vectors) of Vector3d. Two use-cases must be satisfied:
1) The trivial case in which the data are stored as stl vectors of Vector3d;
2) The more difficult case where the individual components are stored as stl vectors of double, and are not guaranteed to be contiguous in memory (so one cannot rely on "stride").
Assuming the array lengths are all identical, I'd like to be able to access both types in a single loop. The straightforward way for case 2) is to construct a temporary Vector3d from the three components (indexed with the loop index). However, I would prefer not to incur the overhead of the constructor.
Is it possible using template metaprogramming. Ideally I'd like a CompositeVector3d that inherits from Vector3d and is constructed with the component vectors, but can be dereferenced using the loop index in the same way as one would do with case 1.
I am not looking for the typical template metaprogramming utility of being able to operate on the entire array without explicit loops. I just want the syntactic "sugar" whereby CompositeVector3d and Vector3d act the same, plus the avoidance of the cost of the constructor. I am not averse to using an additional templated class (perhaps a Field or a View class) to access the basic storage in both case.
Is it possible to do this without using a full template metaprogramming utility?