565 Posted Topics
Re: Daniweb member rules state this: **Do provide evidence of having done some work yourself if posting questions from school or work assignments.** Post what you've done, and we'll take it from there. | |
![]() | Re: Line 20: `mazeFile.open(file);` It should have been `mazeFile.open(file.c_str(), ios::in);` Lines: 121, 129, 137, 143 assignment to itself the `rows=rows` or `cols=cols`. Also, post the entire error. When separating the files into headers and cpp, in the header you should place only the declaration of the function, and in the cpp … |
Re: CrossThread from [http://www.cplusplus.com/forum/general/83448/](http://www.cplusplus.com/forum/general/83448/). This is at most what I could come up with: [Linking libraries with codeblocks](http://stackoverflow.com/questions/5862757/how-do-i-link-to-a-library-with-codeblocks) [Building libraries with mingw](http://www.transmissionzero.co.uk/computing/building-dlls-with-mingw/) | |
![]() | Re: Also, if a there is a static member you could see the total number of instances of that class from your entire program. #include <iostream> using namespace std; class StaticClass{ static int count; public: StaticClass(){ count++; } static void printCount(){ cout<<"Number of instances: "<<count<<endl; } }; int StaticClass::count=0; int main(){ … |
Re: Daniweb member rules sais this: **Do provide evidence of having done some work yourself if posting questions from school or work assignments**. I don't see any attempt of doing this program. Also, we won't just hand you the program. So start working on it, and only when you encounter problems, … | |
Re: Here, this should do it. I just replaced the System.out.println(isPrime(n)); part, which would print true or false, with an if if (isPrime(n)) System.out.println("The number is prime.\n"); else System.out.println("The number is not prime.\n"); Here's the code: import java.util.Scanner; public class PrimeNumber{ public static void main(String args[]){ int n; Scanner Prime = … | |
Re: Looks find to me: /* * Output: * rachelhellogoodbye */ Try with the append function from the string class: while(getline(in,line)){ fullLine.append(line); } Or with insert: while(getline(in,line)){ for (size_t i=0;i<line.size();i++) fullLine.insert(fullLine.end(), line[i]); } Take a look at the getline method. If you don't provide any delimitter, the new line character will … | |
Re: I'll do it like this: Have a function that returns how many words are in a line, i.e. counts the number of spaces. Have a boolean function that checks if a string starts with a vowel or not Tokenize the entire line. Split the line into words. Check each word … | |
Re: [http://lmgtfy.com/?q=sort+words+c%2B%2B](http://lmgtfy.com/?q=sort+words+c%2B%2B) Also, where's your attempt of doing the program? | |
Re: Yes, indeed, but the saddest part here is that he's a member of daniweb since January 2011, having 51 posts already. By now, he should have already read at least some programming books, and if not, well... | |
Re: Indeed, it takes some time to load things up, but otherwise, it's kinda decent. | |
Re: > Then iterate through each character of the string (using for-loop) and display the character using System.out.println(). or wasn't that clear enough? You have in your string the integer: like 150 to string is "150". What does that mean? It means that you transformed your integer into a collection of … | |
Re: try cin >> ch; num1 = cin.peek(); cin.ignore(80, '\n'); cout << ch << (char)num1; as the peek function reads and returns the next character without extracting it, leaving it as the next character to be extracted from the stream. So, if you still have a number, it will consider it … | |
Re: To quote the **Member rules**, which, by the way, you agreed on when you signed onto this site: **Do provide evidence of having done some work yourself if posting questions from school or work assignments**. We won't just hand you the program, it will do you no good, except maybe … | |
Re: Load each line in a string, check if it matches a certain token, update it, than write it to a file. I would suggest using two files, the original, from which you will read, and the other on which you make updates: You read the original file, line by line, … | |
Re: Either you insert the numbers in the array in reverse order and print the array normally for (n=i-1; n!=-1; n--) { cout << "Enter number: "; cin >> p[n]; } or normally insert items in the array, and print them in reverse order for (n=i-1; n!=-1; n--) cout << p[n] … | |
Re: How to find the average of positive numbers? Loop throughout your array/list, count how many positive and how many negative numbers you have, add them sore them in a variable accordingly, positive in one number, negative in another number, say `total_nr_of_positive_numbers` for positive numbers, and `total_nr_of_negative_numbers` for negative numbers, than … | |
Re: **s.rasoly**, if you have a question please start your own thread, and not bump into a 3 year old one! | |
Re: Use `String.replaceAll()` method to delete/replace strings: Here's a quick example to delete a string from a file: import java.io.*; import java.util.*; public class Iofile { public static void main(String [] arg)throws Exception{ System.out.println("Input file: "); BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); String input=in.readLine(); System.out.println("String to delete: "); String del=in.readLine(); File … | |
Re: Well, in your example you can't, because strcat requires two char*, whereas a and b are simple chars. What you can do is to work with strings: #include <iostream> #include <string> using namespace std; int main(){ char a='a'; char b='b'; const char* all; string together; together+=a; together+=b; all=together.c_str(); cout<<all; return … | |
Re: So you want to start programming in 3d, but my question is: what are your programming skills, are you a beginner or an advanced programmer. What are you trying to accomplish with this? Do you want to create a video game? Are you progrmaming a tool that handles 3d objects? | |
Re: I don't quite get where's your problem, but I see you're trying to insert from a file, a matrix, and than display it: Probably the text file looks like this: 5 7 ******* *S***** *****E* ******* ******* where 5 is the number of rows, 7 the number of columns, and … | |
Re: Have you bother looking under Java tutorials? [Here](http://docs.oracle.com/javase/tutorial/essential/exceptions/), this might help you. | |
Re: line 12 it's `++frequency[response[survey]];` not `++frequency[response[surv]];`. Use what **Software guy** gave you, basically, in there is your whole assignment. After that just print in parallel the arrays: the index and the element. | |
Re: Well you could parshe the entire string, find out where the delimitters are, then split them. Perhaps you have some round/square/curly brackets as well, so you'll need to take that into consideration too. For tokenizing: [Click Here](http://www.cplusplus.com/reference/iostream/stringstream/) Converting to double: [Click Here](http://www.cplusplus.com/reference/clibrary/cstdlib/atof/) | |
Re: Hi, and welcome to Daniweb. Looking forward to your questions and as well for an open mind in accepting the critiques/ideas (if there are). | |
Re: Well, Java comes with its own tutorials. I find this website really useful: [Click Here](http://docs.oracle.com/javase/tutorial/index.html) | |
Re: Well probably. What you can do is to make functions of everything inside: if, for example, you have a comparison answer<guess, you could do a function that compares two numbers, if the first one is lower than the 2nd, it will return -1, if they are equal it will return … | |
Re: Let's take it step by step: cout << ++a + ++a + ++a << endl; a=0. ++a increments first the variable, than use it in expression so: a=0; ++a=1; //so ++a + ++a + ++a = 7 a=1| a=2| a=2 2 + 2 |+ 3 | = 7 so let … | |
Re: [http://lmgtfy.com/?q=The+beginnings+of+computer+science](http://lmgtfy.com/?q=The+beginnings+of+computer+science) | |
Re: Another thing you could do is to have a boolean function of checking if there are duplicates in the array. Inside of that function, a for which goes from 0 to array size. So it would take as parameters an array and an int containing its size, and the element … | |
Has anyone notice how much members we got on daniweb? Mine currently shows 1,004,528 members. Anyway, it's a great deal to have 1000000 members on a website. Keep it going Daniweb. :D | |
Re: Indeed, at replying to a thread, when trying to upload a `.cpp` file it yels the following error: `The filetype you are attempting to upload is not allowed.` | |
Re: I would suggest using the [ifstream](http://www.cplusplus.com/reference/iostream/ifstream/) operator when working with files. If, and only if, your text file is filled with numbers, than you could do it like this: â—‹ take first number as min â—‹ start going through all the numbers from the file, comparing each number with your … | |
Re: Well what product do you have? And what are the simptomes? Do you see your wireless light turning on? If you don't you could search google for some applications that will force start your wireless connection. | |
Re: Well, to start you with, what is a loop? It's a task that is repeatedly done till one or more conditions are fullfilled. Examples of loops would be: while (condition){ //do stuff } or do{ //do stuff } while (condition) or for (beginning of condition ; end of condition ; … | |
Wouldn't be nice to have a daniweb application for iphone? I mean, for an easier access to the website. I don't know if this ideea was proposed before, but I would lile to know if you thought of such an application. | |
Re: Try to get out the srand() part from that function. Srand() generates a seed for your rand() function, thus it should be put just 1 time in your program, most likely in your main function since it's the starting point of your program and it is called just 1 time. … | |
Re: Well you could do it like this: #include <cstdio> #include <iostream> using namespace std; int main(){ cout<<"\\\\: "; char c; cin.get(c); cin.ignore(); if (c!=' ' && !isdigit(c)){ cout<<"Ok: "<<c<<".\n"; } else cout<<"Not ok.\n"; return (0); } `cin.get(c)` will put just the first character from the input stream, even if you … | |
Re: use what **WolfPack** told you: //class ....{ int acc() { return (account_number); } //etc. } Also uxi[i].user(acno,amount,pass); will be useles. I suggest you to use the [vector](http://www.cplusplus.com/reference/stl/vector/) class ftom std to store your objects. And, BTW, took me 5 minutes to see where the class ends, and where the main … | |
Re: Well you'll need something to get the input from the user, and than to separate that input in parts that will be stored in the array. Say, if you need to insert grades, I'll recomand you a class in which you'll get the whole stream inserted by the user, as … | |
Re: You'll be needing 2 nested loops, each one to 9. If you analyze a bit the pattern you can see that it's a square with i=9 and j=9: i/j0 1 2 3 4 5 6 7 8 0 A - A 1 A - A 2 A - A 3 … | |
Re: And have you tried to solve this or you just want to be handed the answer? No one will do your homework because: 1. Probably they can spend their time doing something else. 2. THIS WILL NOT HELP YOU AT ALL. Programmers don't just appear after graduating a highschool or … | |
Re: Have you tried to do some thinking/coding? We can help you as long as you show us something. We don't do homerworks/lab assignments. | |
Re: Here are some avaible information about this: check those libraries, maybe they come in handy to what you are trying to accomplish [Click Here](http://stackoverflow.com/questions/870460/java-is-there-a-good-natural-language-processing-library) | |
Re: I'll go aswell with the stringstream methods. It's form the standard libraries, and it's not that hard to implement. Have a look at the link that **mike_2000_17** posted, you'll find everything you need there. If you fancy, you can use the [istringstream](http://www.cplusplus.com/reference/iostream/istringstream/) (which manipulates strings as input streams) or/with [ostringstream](http://www.cplusplus.com/reference/iostream/ostringstream/) … | |
Re: I would suggest you do it with a string instead of that int as the chosen variable, in order to rule out possible errors. I also would suggest using a for loop, and inside of it to make your validation via the if-else clauses. Here's a quick example of how … | |
Re: You can insert the ascii in the file using a csi (comma separate items) method, like 100,101,102,103 than getting from the file, having the comma `,` as the delimiter and than converting to characters. It would probably suite you better. | |
Re: So you want to get a string in which you'll store random characters from the name, pet and birth date rite? I would suggest using instead of that `char name[max]` thing, strings, for an easy use. Also, I would get the input from the user, and than form a string … | |
Re: Here's the link from wiki [Click Here](http://en.wikipedia.org/wiki/Knapsack_problem) Here's a good totorial on the knapsack problem using dynamic programming [Click Here](http://www.youtube.com/watch?v=EH6h7WA7sDw) maybe this approach would suite you better than the "hard coding" one. |
The End.