- Upvotes Received
- 0
- Posts with Upvotes
- 0
- Upvoting Members
- 0
- Downvotes Received
- 1
- Posts with Downvotes
- 1
- Downvoting Members
- 1
11 Posted Topics
Re: Heres a simple solution using the stl #include <iostream> #include <algorithm> #include <vector> int main() { //sort using a char array. char cArr[] = "15462"; int len = strlen(cArr); std::sort(cArr, cArr + len); std::cout<<"Sorted char array is: "<<cArr<<"\n"; //or we can sort on vector or any other container std::vector<int> num; … | |
Re: Your code compiles ok on vc++ 6. Your only calculating the julian day number using year, month and day. You need to do the same for year2, month2, day2 and then find the difference between the two julian numbers. | |
Re: If your working with MFC, theres a function CreateProcess(.........) That will launch an exe in its own thread. Its up to you to keep peeking at any messages it sends. Dont know if this is what you want, but its the closest thing i could think of | |
Re: Have you thought of using the sort algorithm in the stl, and a compare func struct containerCompare { bool operator()(const Type& p1, const Type& p2) const { //compare your elements here } }; std::sort(container.begin(),container.end(),containerCompare()); | |
Re: Fist thing you need to do is change the prototype of triangleShape. Since it has to usethe lengths of the triangle you need to pass them into it. It needs to look like [CODE]....triangleShape(float A, float B, float C)[/CODE] I think your instructor means you to have shape of type … | |
Re: Just to agitate things up a little. The problem can aslo be solved by use of const or non-const reference members and is similar to the pointer version. [CODE]class classone { public: classone(const classtwo& classtworef) :m_classtworef(classtworef) { //reference members can only be initialized in member initialization list } const classtwo& … | |
Re: Firstly, a struct is almost the same as class. The only difference is that evrything is public by default. For a class the default is private Secondly what you are trying do do with the cast is wrong. The compiler will let you cast anything to anything. You cannot cast … | |
Re: Heres a snippet in mfc for finding a file of form *.extension in directory = myDirectory [CODE] // Get a list of files CFileFind finder; BOOL finding = finder.FindFile (myDirectory + CString ("\\*.") + extension); //iterate the results while (finding) { finding = finder.FindNextFile(); //get file path CString path = … | |
Re: You can use max_element #include <iostream> #include <vector> #include <algorithm> using namespace std; int main(int) { const int len = 3; const int start = 0; double arr[len]; arr[0]= 2.4; arr[1] = 1.2; arr[2] = 3.67; double* first = arr; double* last = arr + len - 1; //get min … | |
Re: Swithc works with integral types, so inPlanet (float) will not work. Instead, try this cin >> planet; | |
Re: atoi requires const char*as an argument. string is a specialization of basic_string and is not a const char*. Call method c_str() on the string to get const char*. string owns the memory for the char buffer, so make sure your string goes out of scope after you have finished with … |
The End.