466 Posted Topics
Re: How are you currently trying to change it? And, what exactly goes wrong when you [i]do[/i] try to change it? | |
Re: I tend not to use predefined [icode]MAX_NUM[/icode] or [icode]MIN_NUM[/icode] values when finding the min and max of arrays. Instead, I tend to initialise the min or max to the first value of the array and then loop over the remainder of the array. So, in your case a [icode]findMin()[/icode] function … | |
Re: [QUOTE=MasterGberry;1446991]Because it is a long int value, and is not in hex value? I am not sure if it will or will not work. Thats why I am trying to get opinions on it. Or can C++ automatically compare a hex value to its long int equivalent?[/QUOTE] I don't think … | |
Re: I may have mis-understood, but you could declare your class as [code] template <typename T> // Replacing template< int T > class BruteForce { private: int currentItem, nextItem; std::queue<T> q; public: void MakeQueue(); void GetPercepts(); int reflexAgent (int,int); void DisplayInfo(); }; [/code] This should allow to to create a [icode]BruteForce[/icode] … | |
Re: It's easier if you put the types of the variables too. From what you have above, I think that you have this: [code] int value = 25; // A variable that you implied was equal to 25 int *beth; // A pointer to an integer int *ted = &value; // … | |
Re: You can use the STL [icode]std::transform()[/icode] function to convert the whole line to lower case using a single line of code: [code] #include <iostream> #include <string> #include <algorithm> // std::transform is in here int main() { /* Make a string, this is a tough one, with lots of things to … | |
Re: I don't know if this exact same thing exists, but you could do something similar using the [icode]std::map.find[/icode] member function. [code] std::map< char, int >::iterator it = myMap.find(myKey); if(it != std::map::end) value = *it; [/code] | |
Re: I think you have line 11 backwards, it should be [code] alphabet[i] = line[i]; [/code] also, I'd probably just change the program so that it looks like: [code] int main() { char alphabet[27]; cin.getline(alphabet,27); char line[50]; cin.getline(line, 50); /* Do things with line now */ } [/code] This has the … | |
Re: [QUOTE=Narue;1441684]It eliminates the need for a std:: prefix by importing all of the names in the std namespace to the current scope. That can be a bad thing because you're not likely to use all of the names that were imported, and you might be using other libraries that use … | |
Re: Try replacing the [icode]do{ ... }while()[/icode] loop with a [icode]for[/icode] loop, like: [code] for(unsigned i = 0; i < numOfSplit - 1; i++){ endPos = src.find_first_of(delim,startPos); std::string::size_type length = endPos - startPos; if(length != 0) result.push_back( src.substr(startPos,length) ); startPos = endPos + 1; } [/code] This would also fix the … | |
Re: When you start the [icode]int[/icode] with a zero, I think it's getting interpreted as an octal number and then output as a decimal conversion of this. Try the code below: [code] #include <iostream> using namespace std; int main() { int x1 = 010; /* interpreted as an octal number */ … | |
Re: It's almost certainly not a problem that's caused directly by putting a [icode]break[/icode] in the [icode]while[/icode] loop. It will be something to do with the many custom functions that you have in there. However, we can't see what they are at the moment. I'm not asking you to post the … | |
Re: I'm guessing from your code that you might want to keep executing the lines that tell the user to chose a number and then process the choice to output the correct line from the switch statement. You could do this by recursion (although you have it a bit muddled here, … | |
Re: Yeah, I don't know but I'd imagine that this would be a massive security hole if the operating system let do it! In any case, I don't think that there's anything that you could do in C++ that would give you this behaviour, since your C++ code doesn't come into … | |
Re: Which particular nested loops are you talking about? Perhaps it would be better to give a small test program as an example, one that contains only the bit that you want to know how to fix. This way people will be able to see how to help you a bit … | |
Re: There are 3 [icode]getline()[/icode] calls in your example, which one is causing the problem? Could you make a simple piece of code that shows the problem and doesn't have a lot of extra stuff in it? That way it might be easier for people to help you out. | |
Re: I don't use this library or anything, but what it sounds like you want to do is dynamically create some equivalent to [code] vector< someType > origin; [/code] so that you can later refer to it like: [code] origin.at(n).doSomething(); [/code] I don't think you can do this. The way that … | |
Re: I'm assuming this is a kind of simplified version of what you're actually trying to do, since this is a very simple example. If so, then you can multi-thread your code using an external library, there's no in-built multi-threading in C/C++. Popular cross-platform libraries for this are the Boost.Thread library … | |
Re: If your professor has made it compulsory to use TC++ then couldn't you ask him/her to provide you with a working version that includes all the header files that you need? If not, then what is the error that tells you that windows.h is not included in your version of … | |
Re: If that is the actual code that you're trying to compile then you should also be getting an error from the compiler due to the lack of braces to enclose the [icode]main()[/icode] function. Also, when you declare the header files you have use [icode]#include <iostream.h>[/icode], which is deprecated. Instead, you … | |
Re: I do not get the behaviour that you describe. For input values of n = 1 and m = 10, [icode]getOps()[/icode] returns 3 and [icode]ops[/icode] is set to 4. This is because, in this case the [icode]getOps()[/icode] returns from line 8. Since you're using [icode]ops++[/icode] the value of [icode]ops[/icode] is … | |
Re: You can read in files using [icode]fstream[/icode] objects. I posted something about this a couple of days ago [URL="http://www.daniweb.com/forums/thread331237.html"]here[/URL] (you have to scroll down a bit to get to the part where the original poster has got their point across). Give that a go and see how you get on. … | |
Re: Are you initialising [icode]s.top[/icode] to 0 before you try to do [icode]top++[/icode] or [icode]top--[/icode]? | |
Re: Hi There, I think line 5 has a missing "*" between 255 and [icode]sizeof(UINT8)[/icode], it should read: [code] VidZone[Loop].pui8Source[FileIndex] = (UINT8 *)malloc(255 * sizeof(UINT8)); [/code] Also, please use [ code ] tags, as it helps other people understand your code. | |
Re: line 16 is [icode]for(int j=0;j++;j<5)[/icode], it should be [icode]for(int j=0;j<5;j++)[/icode] (the [icode]j++[/icode] and the [icode]j < 5[/icode] are swapped around). | |
Re: You could assign each star sign a number then store each of the two choices in a variable and compare them afterwards. I would also break your code into pieces by making some functions that work out the star sign and do the comparing. Like this: [code] #include <iostream> #include … | |
Re: What code have you written so far? If you post the bits you have then people can help you to improve it so that it does what you want it to. | |
Re: Your "=" operator is just returning the original vector. You need to set the values in the current vector using those from [icode]b[/icode] I think you should use something like: [code] const Vector &Vector::operator=(const Vector &b) { x = b.x; y = b.y; return *this; } [/code] The [icode]return *this[/icode] … | |
Re: You're passing [icode]choice[/icode] by value to the function [icode]menu()[/icode], I think that you should use: [code] menu(&choice); [/code] | |
Re: What is it that you don't know how it works? VC++, XML, C++, [icode]fstream[/icode] or all four? | |
Re: OK. Do you have a problem that you don't know how to solve? Or a question that needs to be answered? If so, you might need to post a few more details before anyone can help you. What do you mean by "without repeating"? If you want random numbers between … | |
Re: You probably need to just have a quick look at the methods in the [icode]std::string[/icode] class, [URL="http://tinyurl.com/2w3v7gw"]try this[/URL] :o) | |
Re: OK, I think I see roughly what you're trying to do. I have some general points though: line 22: Be careful of reading text in like this, it's delimited by [i]any[/i] whitespace. So for a line like [code] <a href="http://www.some.url.com" target="_blank"> [/code] your variable [icode]line[/icode] with take the value [icode]<a[/icode] … | |
Re: Are you doing this as an exercise in learning more C++? If not, then there are probably already a bunch of things that can do this already. If you're going to do it as a project to learn something, then you should probably start by trying to find some details … | |
Re: You need some code between lines 72 and 75 to actually populate your vector with the information that you have about the letter counts. This is where the [icode]std::vector::push_back()[/icode] method that jonsca is talking about would come in. So, you'd have some loop that looked like: [code] for(int i = … | |
Re: Please don't hijack threads. Start a new thread for your question, and use code tags for your code. | |
Re: Hi, your code is almost complete! But there are a couple of things that you should consider to tidy it up a bit. Firstly, when you check for a file being open, it's better to check if it's [i]not[/i] open. This way, the whole of your code doesn't end up … | |
Re: I don't know what the solution is, but the problem seems to be with visual studio not being able to find any of the dll that it needs. Did you try a forum for visual studio, or searching for any of the errors on Google? | |
Re: What does it mean to say [icode]*max > *iter[/icode]? This is comparing two strings and asking which is greater. I'm not sure that you can do this. What would be the result of "hello" > "Monday", for example? Do you need to use [icode](*max).length() > (*Iter).length()[/icode] instead? Also, I think … | |
Re: OK, [icode]CvRunningAvg()[/icode] seems to be a function from the Emgu OpenCV .NET implementation. You might have more luck posting this problem on their discussion forum at [URL="http://www.emgu.com/forum/viewforum.php?f=8"]http://www.emgu.com/forum/viewforum.php?f=8[/URL], since there will be many more people familiar with this specific set of libraries there. A piece of advice though: They're [i]definitely[/i] going … | |
Re: Hi there, This isn't something that I've done my self before, but to write the data back to the file I think that you need to open the file with [icode]r+b[/icode] like you said and then use [icode]fseek()[/icode] to get to the part that you want to start writing and … | |
Re: Hi there, If I were you, I'd split the program by making two functions, one that reads in the temperatures and another that gets the average. (I'm assuming that you want to average the high temps. across the week and the same for the low temps, if you want to … | |
Re: You probably need to be a bit more detailed about what it is that you're trying to do here. For example, what do you mean by "add two equations"? Also, you're more likely to get some useful advice if you've attempted to write some code, but it has a problem … | |
Re: Hello, This code is indeed in C, and there are some things that you're trying to do that would be easier in C++. However, I think your problem here is that you have [ICODE]#define MAX_ELEM 365[/ICODE] and then you declare [ICODE]double A[MAX_ELEM][MAX_ELEM][/ICODE], which is going to try and reserve 365x365 … | |
Re: You have no hope of a reply to this request without more details. [icode]sPSActionControl[/icode] appears to be from the Adobe Photoshop SDK, maybe it would be better to ask about specific error codes on the forum for this specific SDK which is at [URL="http://forums.adobe.com/community/photoshop/photoshop_sdk"]http://forums.adobe.com/community/photoshop/photoshop_sdk[/URL] | |
Re: I'd do this: read your data into [ICODE]std::list< std::vector< int > > data[/ICODE]. then you can use a series of loops like: [CODE] std::vector< int > allResults; /* Go through all the lines, using an iterator */ std::list< std::vector < int > >::iterator it = data.begin(); while(it != data.end()){ int … | |
Re: What are the errors? When do you get them (during compilation or when you run the program)? | |
Re: OK, this problem is not that hard and there are people here who can help you. However, you need to give people something to go on. For example, you say that your code doesn't work, but you don't say what it's supposed to do if it did work. It appears … | |
Re: Just a quick note on your code: you should use [CODE] #include <iostream> #include <cmath> #include <iomanip> [/CODE] instead of [CODE] #include <iostream.h> #include <math.h> #include <iomanip.h> [/CODE] These are the old, C-style way of doing it :o) | |
Re: It sounds like you don't know a whole lot about programming in general. Is there a special reason why you want to attempt this in C++? If not, I would suggest that you make a spreadsheet in Excel (or your favourite open source spreadsheet program). You could have the names, … |
The End.