Just tested it with the changes mentioned, and it works for me too.
OmniX commented: Perfect example, thankyou. +1
Just tested it with the changes mentioned, and it works for me too.
Instead of: int board[4][4];
Replace with: int** board;
Now we can dynamically allocate space for the 2D board array.
In set_board(), we need to do the dynamic allocation like so:
// First allocate for the first dimension
board = new int*[height];
// Now allocate for the second dimension
for( int i = 0; i < height; i++ ) {
board[i] = new int[width];
}
The lowercase part you have actually won't work for all cases...
What I would do is just have a boolean variable for each condition, and each check will set the appropriate variable to true or false. Then at the end just 'and' them all together to get whether it is valid.
So for lowercase, have the isLowercase variable set to false, then loop through and once you find a lowercase character, set it to true. Same goes for uppercase and digit.
The other option is to just sort both arrays which will make traversing the arrays and finding non-duplicates much easier.
Not sure where to start on this one... You haven't really followed the instructions. The instructions state that EACH student data record should be dynamically allocated. Instead your student list creates a static sized array of 100 records. What you need to do is make a StudentRecord class which stores info about one student. Your StudentList class should have add/remove/search methods. The add method should create a new instance of a StudentRecord object (dynamic allocation) and add it to the list. The code to ask for student details should NOT be in the StudentList class, but in the main and then passed to the add method.
Also, a menu-driven system should have a loop, otherwise you can only do one operation.
When adding the node at the end (as you are now doing), you should have the new node point to NULL instead of head. The reason you get it infinitely repeating is because when your end node points to the head (the start) it is basically a giant loop.
What exactly are the requirements? Are you supposed to be adding new nodes to the beginning of the list or the end of the list? Are you sure you are not supposed to get the result you got?
In the case that you are supposed to append to the END of the list instead of the beginning as you have done, then you will need to loop through the entire list and put the new node at the end when adding a node. This is clearly inefficient, but if the requirements state that you should be adding to the end of the list then that's what you have to do.
If the requirements say that you should be getting '2' as the output for your example, but specifies that you should be adding new nodes to the start of the list, then that's messed up.... The only real way to fix that case is if you keep track of the length of the list as you insert/remove nodes and then subtract the actual found location from the length of the list (and then -1 since it is 0 indexed). So in your example you would do 3 - 0 - 1 = 2.
Since you are adding nodes to the head (start) of the list, the last node you add will be in position 0. The output is correct for the example you gave. I'm assuming the list isn't supposed to be sorted - if so then you need to change your add function.
Did I say I don't know how to build a GUI from scratch? What is wrong with using a tool that makes the GUI design process quicker?
I usually use Eclipse, but switch over to Netbeans when I do any sort of GUI.
To add two times as you have listed, first add the seconds together. If the seconds > 59 you will have to use modulus (%) to find the remainder of the seconds. You can then use this information to figure out what the actual seconds are and that a minute carries over. Now repeat with minutes and days.
Generally when you are doing recursion on any kind of collection of items (lists, arrays, even strings) you want to solve the problem for the first element of the collection, then recurse on the remaining part of the collection.
For this example you can look at the first element of the list, check if that is the object you are looking for. If it is, then you are done. If it's not, you recurse on the rest of the list (without that first element).
Now, because your function is only taking the list and search object as a parameter, you have no way of sending a portion of a list to recurse on. What you will have to do is create a second recursive function (often called the auxiliary recursive function) that takes an additional parameter of the location in the list to start searching from. When someone calls your original function, you just call the auxiliary function with the location as 0.
Try coding that up and if you have problems, post both functions.
You shouldn't ever be returning the operators though, only the result of operations or the number value in the node.
In the first branch, after you apply the operator to the two children, you should get back a double then return that.
In the second branch you should be returning the value (which is a double).
You have allocated space for all of the studentInfo pointers here (except the last one, you should not be subtracting 1):
struct studentInfo *students[numOfStudents-1];
But, you have not allocated space for the actual studentInfo structures that each pointer will point to. To do that you will have to make a loop that allocates a studentInfo for each pointer using malloc().
Something like:
students[i] = (studentInfo*) malloc( sizeof(studentInfo) );
It should be
readfile >> sample;
since you are getting input, not outputting.
I have not used them, but I believe the boost library has threads and you can try pthreads as well.
I can guarantee you the problem is not winsock, it is something you are doing.
Can you post a little code where you are having the problem, tell us what you are trying to send and what you are receiving?
Vertices are the points or corners of a polygon. So a square is a polygon with 4 vertices, a triangle is a polygon with 3 vertices, etc.
To be a bit clearer, you can use the stringstream class like so:
#include <iostream>
#include <sstream>
using namespace std;
int main() {
stringstream ss; // our stringstream object
int a = 1, b = 2, c = 3;
ss << a << b << c; // we insert a b and c into the stringstream
cout << ss.str(); // call str() to get the string out
system("pause");
return 0;
}
For more info on stringstream check out: http://www.cplusplus.com/reference/iostream/stringstream/
Are you trying to convert a string of digits to a number you can do calculations with? If so, you can you atoi().
http://www.cplusplus.com/reference/clibrary/cstdlib/atoi.html
The first error means that the function ingresar_datos has never been declared - if you look through the code, there is indeed no function with that name.
The rest of the errors are because the function prototype is slightly different than the function definition. For example, for menu you have the following as the prototype:
char menu (char);
But the following in the actual definition:
char menu (char &ingresar)