C++ :: In What Type Intermediate Result Of Expression Is Stored
Jan 8, 2013
my doubt is :- in what data type the intermediate result of an expression is stored? like for expression 2+3*1/2 , i think the intermediate result for 1/2 is stored in the form 0.5 but for expression 2+3*1/100 , i think the intermediate result for 1/100 is stored in the form 0.01 so i am not sure if the compiler use dynamic type ie, changes with need. or it always stores in high precision like:- for 1/2 its 0.5000 and for 1/100 also 0.0100 or something like that.
I am making a program that allows you to add two big numbers that are larger then what int can handle together. I think I have done everything to accomplish this but when I try to instantiate the program I get a error Expression must have a class type.
Here is my main file that is supposed to instantiate the program.
I'm trying to learn recursion, and I'm using a simple array to experiment with it, but I have a couple of annoying errors that I don't understand why they're there. Here's the code:
Code: #include <cstdlib> #include <iostream> using namespace std; int largest(const int arr[], int lowerIndex, int upperIndex) { int max;
[code]....
Now try to print the array backwards:
//Use a recursive algorithm to find the largest element in arr: int largest(arr[], lowerIndex, upperIndex);//error: expected an expression return 0; }
// Purpose: To write a program that displays the number of millimeters higher the current level the ocean level will be in // in 5, 7, and 10 years.
# include <iostream> # include <string> using namespace std; int main() { float X = 10; string Y="";
[Code] ....
But I get the following error message:
IntelliSense: expession must have integral or unscoped enum type
three times in a row for lines 25, 27, and 29 and I don't understand or know why?
In case the purpose does make sense here are the directions:
2.7: Ocean Levels
Assuming the ocean’s level is currently rising at about 1.5 millimeters per year, write a program that displays
•The number of millimeters higher than the current level that the ocean’s level will be in 5 years, •The number of millimeters higher than the current level that the ocean’s level will be in 7 years, •The number of millimeters higher than the current level that the ocean’s level will be in 10 years,
Output labels:
Each value should be on a line by itself, preceded by the a label of the form:
In X years the ocean's level will be higher by Y millimeters.
where X is the number of years (5, 7 or 10) and Y is the value you calculate.
The documentation of the class filebuf in the reference of cplusplus.com says:
Objects of this class may internally maintain an intermediate input buffer and/or an intermediate output buffer, where individual characters are read or written by i/o operations. These buffers are synchronized with the contents of the file once filled up, when explicitly requested to do so (sync), or when the object is closed.
Objects of this class may be explicitly made unbuffered by calling member pubsetbuf with both arguments set to zero (see member setbuf): Unbuffered file stream buffers perform the i/o operations directly on the file, without an intermediate buffer.
The C++ standard ensures that filebuf objects have an intermediate input/output buffer/s (i.e, the default constructor of the class filebuf creates the intermediate buffer/s)?
The standard C++ library only allows unbuffering filebuf objects (as the above quote says) but doesn't allow forcing filebuf objects to be buffered.
I have been seeying the concrete implementation code of the standard C++ library in my Windows Operating System (Windows 7 Ultimate 64 bits Service Pack 1) and it seems that fielbuf objects never uses intermediate input/output buffer/s, they use FILE streams of the standard C library instead to do the work. Are this FILE streams always buffered? If true, are they fully-buffered or line-buffered? what is the size of the buffers (perhaps macro BUFSIZ from <cstdio>)? and can I change this size?
I am worried about performance in reading and writing from/to files: if the default behaviour offers the best performance (perhaps if files are too large is better force buffering and choose a larger buffer size).
I have a compressor that takes a file and first compresses it to an intermediate file "temp.lz", before compressing it to the final format. Immediately after that the file be removed by calling c's remove(char*). The problem I am afraid of is if calling this compressor from different processes is safe because of the intermediate file created which has the same name for all. (say temp.lz). Will I have problems when callinga sytem call from different process something like: system ("compress -i test.txt -o test.z") ?
I was thinking of rewriting the compressor to avoid the use of the temporary file but that is a bit awkward. I just need to use a temporary stream (file) different for each process to avoid race conditions.
I am/we developing in C and we have a number of different programs. We also have problem to keep track of different versions of a specific exe file.
Is there any way to add version number when build a file so the version is added in the properties.
I doing this in a MFC c++ project in a .rc file. Is there a way (or a similar way) of doing this in C? Here its stored in the details section with product version 6.0.8:
I know that memory addresses in the stack can contain either values or references to other memory addresses, but do these memory addresses also contain methods or are the methods themselves located in the heap?
The confusion comes from the fact that in C# a delegate variable can be assigned either a method's identifier, an inline function, a lambda expression, or a new instance of the delegate type with the method's identifier passed as an argument to the constructor. My guess is that assigning the method's identifier directly to the delegate variable is just a simplified way of calling the delegate type's constructor with the method's identifier as an argument to the parameter, something that the compiler handles for you.
But even in this last case, the delegate variable is said to point toward the method itself. In that case, does it mean that methods are stored in the heap, just as reference type values are?
Making a game of checkers on C++ win32, visual studio
when i want a piece to move, i type:
cout << "What piece do you want to move? (C4)" << endl;
i type in 'cin' after to get the players input, but how do i get it to store the players input in a certain variable? im going to have a list of variables:
string a1 string a2 string a3
etc
so if the user types in a2, it automatically goes to that variable and then asks the user "where do you want the piece to be moved to?".
So I'm trying to delete a value stored inside one of my vectors but I can't accomplish this. My attempts are down below. I've commented out one attempt since it gives me errors. How can I do what I am trying to do?
#include <iostream> #include <vector> using namespace std; int main() { vector<vector<int> >row; vector<int> newColumn;
I am trying to build a employee management system using C, and I have done alot so far. Everything seems to work fine, but then I thought that I should let the user store the data of their employees permanently, therefore I created a file and then I store the user's given data in the txt file.
But there is some problem, and I don't seem to understand what is the problem in the code, it's just that whenever the user enters any id to search, and presses any key then nothing appears just a blank screen! I wanted to know that how can I check the ID from the text file and then display the details of the employee of that id!
I have a table in my database that has a 3 fields.
RuleID | RuleName | Rule
the ruleID is a randomly generated string of characters, RuleName is the name the user gives to the rule, and the Rule field is about 600 characters long and is just XML text.
I want to read that Rule field from the database and use it inside the function below.
I'm having some problems with changing an array of numbers of type char to type int. Every time i try to sum 2 array indexed values it returns some letter or symbol. Also, if i change the type of the array in the functions the compiler gives me an error message. I would also like to add that the problem requires that the first two arrays be char so each individual number gets assigned to a different value.
My current code is:
Code: #include <iostream> void input(char a[], char b[], int& size_a, int& size_b); void convert(char a[], int size); void reverse(char a[], int size); void add(char a[], char b[], int c[], int size); int main()
I want to declare a char* array, and then make any future variables declared to be stored in a specific location within the char* array. Is this even possible, and if it is how would I go about doing it. (I plan on storing any primitive data type in it (not classes or structs), and they may signed or unsigned).....