Thanks itsgsd.
I can't believe I didn't think of that.
BTW, It isn't necessary to cast the chars as ints, in fact I was taught casting basic datatypes is bad unless unavoidable, C/C++ handles chars as ints when doing arithmetic.
Are you not allowed to use the delete[] operator on an array that was dynamically allocated in a function with new?
e.g.,
void func1()
{
...
double *a;
func2(a);
delete[] a;
...
}
void func2(double *a)
{
...
a = new double[N];
...
}
I am confused about this...
I am having a problem with atoi() in this function. It works correctly in Windows, putting a shiftAmount that corresponds to the two digits, but fails under Linux/UNIX where, for example, a 2 and a 3 get made into 20 + 32 = 52 instead of 20 + 3 = 23. What's wrong? Is it because I declared my...
I want to read a block of data from an ifstream into an array of doubles. However, the function .read(char* buffer, int size) does not allow me to put the pointer for the double array into where it requires a char pointer. I don't understand why there is this limitation, or how to get around...
I am trying to pass the array "da" from the non_linear_min function to the lev_mrq_min_step function, have it filled with values, and then return it to add it into another array. The problem is, the "da" array appears to be given proper values from it's assignment in the...
I would like to be able to pass a particular function to another function so that I may call that specific function from within the function it was passed to, i.e.:
double func2(int a,long b,double c);
double *func1(long a,long b,*func2(...))
{
...;
func2(...);
..;
}
How does one go...
I've already tried installing from the CD drive and I am sure it does not work. I obviously had to use the boot floppies and the install process is good up until it asks me where the rest of the install files are. I tell it the CD drive and it says it cannot find it. The boot floppy does NOT...
Nonono, what I meant is that the CD-ROM drive is not recognized until DOS starts up and loads the MSCDEX program. The CD drive is not loaded with the BIOS. Does that make sense?
Please don't laugh, as I know just how horrible Packard Bells are. However, I want to use my old 486 box to test UNIX and Linux on. The problem is that all of the distributions I want to install are best installed from CDs and this computer does not appear to have the ability to boot from the...
Wait, so, you are saying that if I malloc() the memory inside the function, I can then pass the pointer with no problem, and all I have to worry about is cleaning up with a free()?
The reason I am making such a big deal is that the polyfit function returns array a with number of elements...
I did allocate memory for a in polyfit, I just thought that could be assumed from my pseudo-code.
Don't get confused because I used a in both functions. It is a local variable.
I want to create an array in an external function and return the pointer of that array so that I don't need to be...
The calculation has an array of coefficients as it's result. I would like to return a reference to that array, as I understand that return cannot actually return arrays, blah blah blah about pointers and stuff. I just want to be able to assign the array created in my polyfit function to the...
I have written a function to calculate the n-degree polynomial fit of a given data set. I made the function in an external file and linked it to another program with a header file. I want it to do something like this, where a is an array for holding the polynomial coefficients:
//main program...
Sorry, none of those suggestions helped because I finally realized that there is a utility on the computer I am programming on called "convert" and it was executing instead of my program and would not accept the arguments I gave it.
I ended up using your suggestion for my original...
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.