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>.
I get an error when i try to compile this code. I tried to allocate memory in main function and that works. But why it doesn't work in function? I think that there is something wrong with function argument, but not sure.
Code:
#include <iostream> #include <fstream> using namespace std; struct Word
in a header file and the header file is included in several C files.
Questions:
At run time,
Is there just one copy of the const variable my_fl_dark_gray or are there multiple copies for the multiple C files?If a function uses the const variable, does the initialization statement "my_fl_dark_gray=fl_color_cube(...);" run every time the function is called or does it just run once and then when the function is called it just uses the value stored in memory?
I am writing a program to calculate a rectangle's area.
Eg. Enter top left point: 1 1 (User input) Enter bottom right point: 2 -1 (User input) Top Left x = 1.000000 y: 1.000000 Bottom Right x = 2.000000 y: -1.000000 Area = 2.000000 (Program output)
It keeps on prompting me my variable r is being used without being initialized, when I think I already did so.
I've created a program meant for submission for my final project but when i ran it, it shows that the variable being used without being initialized for quite a few time. My program is below.
when i compile my code i get this error : "error : variable-sized object 'largeArray2' may not be initialized"
Code:
float give_coefficients_routh_table_and_fill_two_first_lines(int denominator_degree) { float largeArray2[20][20] = {0}; int l = 0; int c = 0; int e = denominator_degree ; for ( e = denominator_degree; e>=0; e--)
Under visual studio, this is a typical run time error,
Code: void func(int x){ x = 3; } int main() { int x; func(x); }
When x is passed to the function func, it is not initialized. But my question is that why it should be an error? On the other hand, if I change the definition of func a little bit like this,
Code: void func(int& x) { *x = 3; } int main() { int x; func(&x); }
Now in main, x is still not initialized, but this time there isn't a run time error like "the variable is being used without being initialized. Why?
Basically when I type in different widths and heights for the col and rows, the buttons that make up the width get cut off. Something is messed up but I'm not sure what!
InitializeComponent(); int _col = int.Parse(cols); int _row = int.Parse(rows); int width = groupBox1.Width; int height = groupBox1.Height; int bW = width / _col; int bH = height / _row;
The program is when a person clicks a button this button updates 2 separate listbox one tracks the total rolls the other displays the total amounts of frequency afterwards adjusting labels as a scaling measurement.
The problem I am having is right at the end where I am trying to adjust the width of the label this is what I have. It is highlighting the word "Items" for each label and says that Non-Invokable member 'System.Windows.Forms.ListBox.Items' Cannot be used like a method L2 is a label. Additionally I have added in the information for one of my loops below the line I am having trouble with this loop is created to determine how many lines are in the listbox of rolls and I have no trouble with this just thought id add it for additional information I dont think I need to add the rest of the code but I can if needed.
L2.Width = int.Parse(lstfrequency.Items(0).ToString()); TL = 0; for (I = 0; I <= 10; I++) { TL += int.Parse(lstfrequency.Items[I].ToString()); } lstfrequency.Items.Add(TL);
Define functions n(), s(), e(), w(), center(), ne(), se(), sw() and nw(). Each takes a Rectangle argument and returns a Point. These functions define connection points on and in the rectangle. For example, nw® is the northwest (top-left corner) of a rectangle called r.
I wrote below code for that:
#include <Simple_window.h> Point n(const Graph_lib::Rectangle& r); Point s(const Graph_lib::Rectangle& r); Point e(const Graph_lib::Rectangle& r); Point w(const Graph_lib::Rectangle& r); Point ne(const Graph_lib::Rectangle& r); Point se(const Graph_lib::Rectangle& r);
[Code]...
As you see, this just mark the top-left corner of the rectangle r. In other functions I need the specifications of that rectangle, for example its height and width. How to use these specs in those functions?
I am drawing two circle (inner circle and outer circle) using DrawElipse method. I have created two pen object named OuterPen and InnerPen and creating Outer Circle using OuterPen and Inner Circle using InnerPen. Problem that I am facing is that when I increase the size of outer pen lets say 10px then it overlaps the inner circle and inner circle is hide. How can I increase the size of OuterPen outwards and not inwards so that it don't overlap the inner circle?
Code: #include <stdio.h> int main() { float number1, number2; printf("Enter two numbers separated by a comma "); scanf("%f,%f", &number1, &number2);
[Code] ....
When it prints the values, it prints them as I want. the problem is, what happens when someone puts in values with different width and precision? Here I had to write in the width and precision to display the values that are specified in the book. but what happens when someone puts in something that doesn't have those width/precision?
I end up with a lot of zeros after the number. initially I got 24.000000 (zeros are not accurate amount) I needed to show just 24. (with the decimal)
So I included %2.0f which gave me 24 (without the decimal point) what if some one put in 24.556. I got 25 as a result.
Does the width mean how many numbers in total including the decimal point and that is a minimum?
I am trying to set the width of the data values which the user will input when using the program but I don't know how to get it to show the values when I tryto set the width of the variables in a nice column .
I derived a class from CRecentFileList in order to set the number of displayed chars for MRU.
The problem is that if I open the app with 256 set for this number (it is read from .ini file) the display is correct. But after I change it to 10 for e.g., File menu width remains unchanged altghough MRU are correctly displayed on 10 (or at least file name lenghts) chars.
how can I tell to the menu to shrink to actual width?
How would I make it so that I can have someone input the length, width and height for all 3 boxes and then have it output the sum and average volume? Here's an example of what I would like:
INPUT - Enter Box 1 (Length, Width, Height): 10.1 11.2 3.3 INPUT – Enter Box 2 (Length, Width, Height): 5.5 6.6 7.7 INPUT – Enter Box 3 (Length, Width, Height): 4.0 5.0 8.0 OUTPUT – The sum of the volume is 812.806 OUTPUT – The average volume is 270.935
Here's my original code:
#include <iostream> using namespace std; double box(double length, double width, double height); // use double data int main() { double sum; sum = box(10.1, 11.2, 3.3) + box(5.5, 6.6, 7.7) + box(4.0, 5.0, 8.0);