It's not table.sort() but std::sort(table.begin(),table.end(),table.begin());
Include <algorithm>
Since table is a 2d vector (of what I don't know) you will most likely have to also code a comparison function that compares two table entries.
It's not table.sort() but std::sort(table.begin(),table.end(),table.begin());
Include <algorithm>
Since table is a 2d vector (of what I don't know) you will most likely have to also code a comparison function that compares two table entries.
Its not erased in IE8 either. Maybe that is intentional???
Its funny that you used that in the square2 function, because I just did the same thing before reading your post.. Is it okay within the c++ language to code like that?
Did you try it?
Real numbers include both positive and negative numbers. Your use of the term "real numnbers" is misplaced.
You need another sum and count for all positive values. Then in the while statement add an if statement to sum up all values >= 0 (0 is also counted as a positive value).
square2() calculates the squares of the two values using local parameters. Those values (c and d) are destroyed when square2() returns back to main so main() never knows about them.
What you want to do is set the value of a and b to the values of c and d before square2() returns. Or just simply code the function like this
void square2(int& a, double& b)
{
a = a * a;
b = b * b;
}
He forgot to make array a pointer int* array = new int[size];
Memory is in bytes, not bits. Don't confuse the two.
Are you trying to ask how to find the size of a variable? For example
char buf[255];
printf("size of buf is %d\n", sizeof(buf));
The sizeof operator (its not a function) can not be used to find the memory size of pointers
char * buf = malloc(255);
// The next line will give you the wrong size
// unless you want the size of a pointer and not
// what it points to.
printf("size of buf is %d\n", sizeof(buf));
It would be a lot simpler and faster to wait until all the data has been read and then sort it. Just use std::sort() to sort all the data in the vector at one time.
If you want main() tgo know the squared values then square2() has to chane the values of a and b.
use sprintf() to format the file name
char filename[255];
int i;
for(i = 1; i< 10; i++)
{
sprintf(filename,"p1%03d".state",i);
printf("filename = %s\n", filename);
}
why bits? The smallest addressable memory location is a byte -- usuually 8 bits. And how to get the amount of RAM is operating system dependent.
what compiler are you using?
Before you can use fieldarray you have to allocate memory for it. For example:
// allocate enough room to store two pointers
filearray = malloc(2 * sizeof(char*));
I meant what programming language (c, c++, java, vb, shell, etc)
post the code you have so far.
>>Can anyone help me how to do sample codes for these?
What language?
on line 32 filename is used before it has been allocated. filename is nothing more than an unallocated pointer.
Since this is a c++ program instead of C, suggest you use std::vector<std::string> to hold filenames instead of that structure you declared on line 1.
displayObject() returns void -- that can't be used with cout.
Why all that crazy code??
__int64 a = 123;
__int64 b = 234;
__int64 c = a+b;
>>Using a third variable is so passe for integer values
Possibly -- but that doesn't solve the requirement.
I reviewed your two thread and see that you have not answered people's questions. We are not mind readers, not is anyone here clairvoyant. Would you go to an automobile repair shop and tell the mechanic "My car is broke. Fix it please.". Of course not -- you have to tell the mechanic what you think is wrong with it.
We at DaniWeb humbly appologize to you for being unable to read your mind or see your computer's monitor.
>>Is this correct
Calculate the SD by hand (pencil&paper) to confirm whether your code works or not
auto is new to c++0x, which AFAIK has not yet been approved by the standard committee. So, for now, its compiler specific.
Oh -- you mean you two don't like that teacher because he makes you THINK? The assignment isn't really all that difficult if you code it in small steps. Sure learning is difficult, but isn't that the reason you are in school?
int temp;
int a = 1;
int b = 2;
// swap a and b
temp = a;
a = b;
b = temp;
It could, of course, be some other problem in the code which just shows up during realloc. Strange things happen after buffer overruns or other problems.
A library of what? Cookbooks? Music? Or just anything?
Microsoft has a walkthrough to teach you the basics of using that compiler. You should read it some time. Here are other tutorials.
const int SomeSize = 5;
const int SomeOtherSize = 5;
class ClassName
{
};
typedef ClassName SomeName[SomeSize][SomeOtherSize];
Memory allocated in a dll must be free'ed in the same dll. Likewise, memory allocated in the application program must be realloc'ed or free'ed in that same application program. You can't allocate in one and realloc or free in the other. The reason is that they use different allocation pools (heaps).
>>and how to fix this problem
There is none, other than to do it correctly.
And more information from one of the Microsoft developers (I think it is) He makes the suggestion how to resolve the problem.
During development I just copy the dll into the project's home directory (where the *.cpp and *.h files exist). That way you don't have to worry about changing the PATH environment variable.
When you compile a DLL project it will generate both the *.dll and *.lib files. The *.lib file is used in the application program that uses the dll just like it uses any other *.lib file from the standard C and C++ libraries. That means you have to add the name of the *.lib file in Project --> Configuration Properties --> Linker --> Input. On the right side of the screen add the *.lib to Additional Dependencies edit box. It should already contain several *.lib files.
After that you have to tell the IDE where to find that *.lib file. Add the path to Project --> Configuration Properties --> General. Then on the right side put the path to the .lib file in Additional Library Diectories edit box.
If you created the project as a DLL project then the configuration type will already be selected for you. You don't really have to do that step. At that point, just hit the Build Solution option
If you don't see a Build menu option -- located just to the right of Project menu -- then you need to change another setting. Select Tools --> Settings --> Expert Settings.
try Ctrl+Z
There are litterally hundreds of examples all over the net. All you have to do is use google to find them. Here is one example.
If you don't know how to calculate the SD, read this wiki article.. It provides some very simple examples.
No -- do you see ++it in for (auto it=tempList.begin();it!=tempList.end();)
? I don't.
>>but I can't remember on how to remove it from the list of items in the loop.
I assume you mean how to remove a node from the linked list. All you have to do is iterate through the linked list until you find the node to be deleted. Then adjust the node->next pointer of the node just previous to the one to be deleted so that it pointer to the node after the one to be deleted. Of course since you have a single linked list the code will have to keep track of both the current node and the previous node.
c++ Forms
private: System::Windows::Forms::TextBox^ myText;
<snip>
String^ str = myText->Text;
Use of the iterator is very similar in concept to normal integers.
erase() returns an iterator to the item in the list that follows the item that was deleted. If nothing needs to be deleted than the else statement on line 13 take affect and the iterator is incremented.
operqating system? compiler? Is he printer connected directly to your computer or is it on a network ?
Post Queue.h
Post the declaration of CQueue.
>>Now I'm gonna go get some sleep. Will get back to programming and thinking about your posts tomorrow.
Good. Better to start again with a fresh mind :)
>>1. malloc should have been done in the main() function, so that free is possible in the main() function.
That isn't necessary. There are several functions in the standard C libraries which allocate memory and are free'ed by the calling application program.
>>so this assingment has some frustrating boundaries
That's because you have failed to read and comprehend what others have told you about your program. Go back to the beginning and re-read our comments, then compare them with your program. You will then see your mistakes. For example I mentioned the problem with free() in your program over an hour ago, in my first post in this thread. Yet you have failed to change it. What's the point of us trying to help you if you just ignore us.
Oh you want to work on home work on company time? That's sealing time from your employer.
Nevertheless, there are programs that will allow you to access your home computer from anywhere in the world. Such as PC Anywere
The two arrays in main() are declared wrong
int main () {
const char array1[50] = {"asgfhararjsrj"};
const char array2[50] = {"wajwarjwrjarjsdafj"};
char *cjj;
cjj=combinearrays(array1, array2);
printf("%s\n", cjj);
return 0;
}
Yes I know what you are looking for -- they don't exist. Use your own compiler -- they are free.
line 15: >>cjj[100]=combinearrays(*array1, *array2);
cjj should be declared as a char*, not an array. And remve the start from that function call/
char* cjj;
cjj = combinearrays(array1, array2);
line 40: that loop will not work. You need to use both i and j counters.
for(j = 0; j< strlen(array2) j++, i++)
text[i] = array2[j];
You can do that only if you have security access rights on the target computer. Compile the program on your own computer then download it to the cgi folder on the target web server.