565 Posted Topics
Re: To overwrite the same line you use the `'/r'` option in your `cout` function. int seconds=1440; for (;seconds--;){ cout << '\r' << seconds / 60 << ":" << setw(2) << seconds % 60; Sleep(1000); } | |
Re: Here, maybe this function can help you: it mimics the function system from Windows: int system (const char *command){ int status; pid_t pid = fork (); if (pid == 0){ execl ("/bin/sh", "/bin/sh", "-c", command, NULL); _exit (EXIT_FAILURE); } else if (pid < 0) status = -1; else if (waitpid … | |
Re: Here you go laddie: with open('test01.txt') as words: ws = words.read().splitlines() wds=" ".join(i for i in ws[1:] if i != '') print (ws[0]+'\n '+wds) | |
Re: Well, if you were instructed to follow some sort of procedures when writing your code, and this is your final project of your year, wouldn't that be of any concern to you that you're trying to do your project in a different way? Were there any constraints related to working … | |
Re: But do you call the fuction accordingly? screen_output() | |
Re: One way, but not the brightest, is to simulate a connection via sockets to your server, where you could retrive information from it. Here's the Python module for it: [Click Here](http://docs.python.org/2/library/socket.html). | |
Re: To make it easy and simple. 1st you must declare an array of ints, having known its size, like: int array [5]; 2nd you must introduce items into the array, by parshing through it and assigning each element to corresponding position in the array. Say, you have an array of … | |
Re: Well you could find this easily by comparing the current word with its inverse: int main(){ string word="radar"; if (word==string(word.rbegin(), word.rend())) cout<<"Palindrome.\n"; else cout<<"Not palindrome.\n"; return 0; } If it's the same than it's a palindrome, otherwise is not. | |
Re: The thinking mainly is wrong, because, on recursive calls, if indeed a vowel is found, it will still return false, because of the last condition. I suggest you take an extra variable, if allowed, which will carry the information: void containsVowel (string s, bool &isIt) { if (s.empty()) return; if … | |
Re: I just want peace for this Christmas, due to every-day fuzz, I tend to get really tired, so the best Christmas present for me would be a relaxing/peacefully time, where I can really rest (death excluded). | |
Re: Well, to answer your question we'll have to clarify some things: memory items are different from the persistent ones (those who are stored on the disk). If the file isn't that big, you can store it, line by line, into the memory, using an appropriate container. Here's a little example: … | |
Re: `cin` waits till the user inserts something into the stream, and after that it takes into consideration the `'\n'` | |
Re: STL has something that can help you: an algorithm that performs permutation. You can apply it to a string, so that you get different words each time, and than comparing to your inner dictionary to see if they form indeed a word. You can save these string in a vector/other … | |
Re: You could do it by using some strings, streamstrings and vectors... #include <iostream> #include <sstream> #include <string> #include <vector> using namespace std; #define SIZE 8 int main(){ unsigned char SOURCE[SIZE]={'3', '9', ' ','0','4',' ','7','d'}; vector<string> destination; string part; stringstream token; token<<SOURCE; while(getline(token, part, ' ')) destination.push_back(part); for (size_t i=0;i<destination.size();i++) cout<<destination[i]<<endl; … | |
Re: Maybe this would help you: [Top clause](http://www.w3schools.com/sql/sql_top.asp) in MySql is `LIMIT number` instead of top. Lookup the syntax. | |
Re: > hi,i am new to programming and i got an assignment which is very difficult,i hope anybody can help me here !! Have you done your part? Have you tried solving this problem, and failed? Please, post your tries here 1st (code - what you have so far), and we'll … | |
Re: Have a look at this post: [Click Here](http://www.daniweb.com/members/938124/Lucaci-Andrew/posts/5#post1888886) | |
Re: Maybe this could help you: [Click Here](http://stackoverflow.com/questions/9847441/setting-socket-timeout?answertab=votes#tab-top) | |
Re: As **mike_2000_17**, NULL is a macro evaluated to 0, in the older includes you could find: #define NULL 0 It is used to asign the "null" value to a pointer (mearly a convention), something that would say it's null/void/empty/limbo. It's not that higly recommanded to asign NULL to non-pointer values, … | |
Re: 1. There are plenty namespaces in c++, manly because everyone can create a namespace: namespace something{ //insert your classes, variables, and code here } 2. `cin` and `cout` are few of the items from the std namespace. Basically `std` namespace conains all the classes and the implementations of the standard … | |
Re: **gobartatti** - As we all can see, you are new to our community. One way of getting you noticed in a good way, and also, to be helped, is to obey the rules (which you agreed upon your registration) and not to embarrass yourself by your posts. I see you … | |
Re: Well you could put two variables, one that will count the correct answers and another one that will count the wrong answers: #include <cstdlib> #include <ctime> #include <iostream> using namespace std; long int random() { return (rand()%100+1); } int main(){ srand(time(NULL)); int x, y, total, answer, correct=0, wrong=0, index=0; for … | |
Re: How can you celebrate it? By taking a picture of that moment, at the right time, so that you can always remember it.  | |
Re: Well you could store all your duds :) into a container, meaning a container of type `struct person`. And, you could iterate over that container, checking for each particular struct, if its name/other characteristics match your search. I don't know if it's exactly what you were thinking of... #include <vector> … | |
Re: Usually it's done using the <fstream> header. > warning C4244: '=' : conversion from 'double' to 'int', possible loss of data This warning applies to line 112 stu1.quiz_average = ((stu1.quiz1/10.) + (stu1.quiz2/10.))/2.*.25; Your quiz_average is declared as an int, but your answer is a double. Try converting your `quiz_average` to … | |
Re: You could create a form/grid layout as **mike_2000_17** suggested, where form stands for a simple form with 2 columns and many rows, and grid with many rows/columns. See the attachement below:  | |
Re: Perhaps you should asign to x it's `sqrt(x)` rather than to a variable that you'll never use. Either `sqrt(x)` is something added which has no effect on the code, or you missplaced the variables. Look a bit to the formulae and than apply the correct transformations. | |
Re: `malloc/calloc` etc. indeed allocates dynamically items to the heap, such as the `new` operator in C++. As it was pointed out before, if you're using a large static array, at runtime, from the start, a big part of your stack will be filled, but if you use memory in a … | |
Re: Didn't these guys help you out? Since you have asked for their help also?... [Click Here](http://www.cplusplus.com/forum/beginner/84640/) Here's something that can help you: this function will return true if the number is a happynumber, or false otherwise: bool happyNr(int a){ if (a<100000 || a>999999) return false; int half1=0, half2=0; for (int … | |
Re: You can always use the sorted set from STD: #include <iostream> #include <string> #include <fstream> #include <sstream> #include <set> using namespace std; int main() { set<int> a; ifstream fin ("filename.txt", ios::in); int nr; string line; while (getline(fin, line)){ stringstream token(line); cout<<line<<endl; token>>nr; a.insert(nr); } set<int>::iterator it; for (it=a.begin();it!=a.end();it++) cout<<*it<<" "; … | |
Re: Daniweb member rules **used** to state this and **it still applies**: **Do provide evidence of having done some work yourself if posting questions from school or work assignments.** Show us what you have done so far, and ask a specific question. The requirements for this problem are quite easy due … | |
Re: Here, maybe this can help you: [Click Here](http://www.daniweb.com/software-development/cpp/threads/437486/string-array-problem#post1885937). Another post on this pig latin converter thing. | |
Re: Also, all these answers can be easily found in any course book, so that's another place where you can look. And also, you can always check the online documentation of the C++ language, which is pretty thick, and has a lot of explanations and example. Here's the link: [Click Here](http://www.cplusplus.com/doc/tutorial/). … | |
Re: > Where is my mistakes? it compiled, but did not write anything into third file Interresting, it worked fine for me: a.txt aaaaa aaaaa aaaaa aaaaa aaaaa aaaaa aaaaa aaaaa aaaaa aaaaa aaaaa aaaaa b.txt bbbbb bbbbb bbbbb bbbbb bbbbb bbbbb bbbbb bbbbb bbbbb bbbbb bbbbb bbbbb output: run: a.txt … | |
Re: And here's the explanation: error: ISO C++ forbids initialization of member 'flavor' [-fpermissive] error: ISO C++ forbids initialization of member 'topping' [-fpermissive] error: ISO C++ forbids initialization of member 'scoops' [-fpermissive] in other words, your compiler does not support C++0x future for initializing class members. | |
Re: One way of doing this is using the function `system` from the header `windows.h` if you're using Windows. #include <windows.h> #include <string> using namespace std; int main(){ string pathOfWindowsPhotoViewer="%SystemRoot%\\System32\\rundll32.exe \"%ProgramFiles%\\Windows Photo Viewer\\PhotoViewer.dll\", ImageView_Fullscreen "; string pathOfPicture="C:\\Users\\Public\\Pictures\\Sample Pictures\\Koala.jpg"; system(string("start "+pathOfWindowsPhotoViewer+pathOfPicture).c_str()); return 0; } | |
Re: Line 8: void write(float*,float); Declaration of function write with only 2 parameters. Line 40: void write(float *number,float,ave,int non) implementation of function from line 8 with 3 parameters (no warning because it's considered another function). Line 20: write(number,ave,non); calling function write with 3 parameters but, function header is declared below the … | |
Re: If you'd want a simple if/else if condition program, maybe this would help you: string rev(char delim, string str){ string return_string; for (size_t i=1;i<str.size();i++){ if (str[i]==delim && str[i-1]!=delim) return_string.push_back(str[i]); else if (str[i]!=delim) return_string.push_back(str[i]); } if (str[0]!=delim) return_string.insert(return_string.begin(), str[0]); if (*(return_string.end()-1)==delim) return_string.erase(return_string.end()-1); return return_string; } but **mike_2000_17**'s version is more raffiner, … | |
Re: Line 14: person & person::greater(person &x) it's incorrect. Remove the `person::` part. The class scope is used only when implementing functions outside the class, where they were define (such as in a .h and .cpp file: in the header you declare the functions, but in the .cpp, you implement them, … | |
So, I've been thinking about it: it's 12.03.2012, and Christmas is approaching fast. Are we going to get a new Christmas theme for the site? | |
Re: Here [Click Here](http://www.june29.com/IDP/files/Spanish.txt), maybe this would help you. Also, on further posts, please make your own thread if in need of assistance, and also, if the thread is more than 3 months old, there is no need to post inside of it. | |
Re: All you got to do now is to print the list print list1 or if you want just the numbers on the same line for i in list1: print i, Here, I took the liberty of re-writing this function, with some validations: import random def Exam(n): try: n=int(n) if (n<2): … | |
Re: As some of the other members pointed out, you could divide your code into multiple functions, making it more clear, and also, more easy to handle when error/modiffications occures. Start by thinking what you need as basic functions: int getInput(){ //cout //cin } Would be one basic one. Another one … | |
Re: The function header is this: T max(T t1, T t2) as for the actual parameters: `(120,14.55);` where 1 is an int, and the other is a double, thus the warning:passing double for argument 2 to T max(T, T) [with T = int]. You have the same type for the parameters … | |
Re: Here's a shortened version of your program: int main (){ ifstream infile; int list[51]; infile.open("infile.txt"); for (int i=0;i<51;i++){ infile>>list[i]; cout<<list[i]<<" "; } return 0; } Indeed, lines 20 and 21 were messing your program up. | |
Re: It's actually like this: having n as 6 for example, divided by 2 is 3. In C++ the array notation starts from 0, so if you want to access the 3rd element, you actually access the 4th: array: 1, 2, 3, 4, 8, 9 index: 0 1 2 3 4 … | |
Re: Shoe[num] Means you have an array of type `Shoe` and you're accessing the element from the array positioned at potition `num`. So, if you have only of element of type `Shoe`, and you try to access it in an array way, you'll most definitely receive an error. | |
Re: **@annajazz** Indeed, in C++ we can have the same name for functions but with different arities. Although your answer is correct, it's not what the OP's looking for. He needs to run concomitant two functions, meaning at the same time. The viable thing he can do is what **deceptikon** suggested, … | |
Re: I would definitely say **Counter-Strike**. We gather from time to time (@ 10 guys or so) and we call it a PC night, where all of us gather with our PC's at someones place, "set-up" a weedy network, and then Hell breaks loose. We usually start @8 PM and it … |
The End.