I am new to C programming and I am trying to compile and run an exponent program my instructor posted for us but it is giving me an error saying:
Warning c4550: expression evaluates to a function which is missing an argument list.
Why this is happening (she doesn't seem to find anything wrong with the code). From what I could gather there is some issue with the math but idk. It is supposed to prompt for the number and the exponent to raise it to, then calculate and output the result.
Code: #include <stdio.h> int main() { int base, exp; long long int value=1;
I wrote the following program to initialize a string after the variables is declared, but it isn't working. A warning is given by the compiler, and the execution of the program shows a strange string. How do I initialize variable word in a separate statement from its declaration?
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).
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 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 have an if statement that should either match a text variable that the user has entered and a another text variable that has been got from an array but they won't match even if they are the same,Im at a lost with it.
I am having trouble compiling my interface. I am trying to store a reference variable as a member variable of the interface object. Compiler says that the variable has not be initiated correctly.
LCD inherits from VisualInterface which is expecting a DisplayDriver object to be passed in (DisplayDriver is another interface, but thats not important).
I pass the displayDriver object in when LCD is instantiated in maininterfaces.zip
I was pasing it before as a pointer but was told that this could cause me problems with memory leaks and a reference was better, but now I cant seem to get it to compile.
I have to write a loop assigning a variable x to all positions of a string variable and I'm stuck. I don't have extensive experience with arrays and I'm also a bit confused about C-String. The problem is below.
"Given the following declaration and initialization of the string variable, write a loop to assign 'X' to all positions of this string variable, keeping the length the same.
char our_string[15] = "Hi there!";
(Please note this is a 'C-string', not C++ standard string.)"
I need to transform a local variable into a global variable so I can use it in one of my functions. I thought about passing the value as a parameter to this function but I can do this since the function is called inside the while loop and this variable counts how many times the while loop does (so the final value is outside the loop). Example to visualize better:
I want to store few different functions to a variable for different structs/classes and then call it later using that variable, is it possible? something like
struct item { int ID; int special; // for function };
item Key; Key.special = UseKey(KEY_KING);
// now when I want to call function "UseKey(KEY_KING)" I want to use "Key.special", like this
I've been experimenting with pointers and am getting the below error.
'error: cannot convert 'int**' to 'int*' in assignment'
I thought it was ok to assign a variable address to another variable. Line 18 is where I get the error.
I am trying to show the progression of memory as I increment it as I have done on line 17 and again, I don't know why I don't see a progression through memory locations when output to the console on line 20.
Here's the code: #include <iostream> #include <cstring> #include <cstdlib> using namespace std; int main() {
Any way to create a variable using a variable in the name? So E.g. if you wanted to create an int named nr(x), and x was 1, you would get an int variable named nr1? How would you do this?
This while statement is not cooperating and I am not really sure why. I tried to say while not equal to true and later false, but both produce a never ending loop. I know I posted this before and I got several comments back about different issues with this program. However this question is specific about the while statement.