565 Posted Topics

Member Avatar for brock.holman.7

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); }

Member Avatar for Gonbe
0
137
Member Avatar for john.halbert.37

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 …

Member Avatar for john.halbert.37
0
217
Member Avatar for thanadaray

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)

Member Avatar for Lucaci Andrew
0
132
Member Avatar for abed.arb

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 …

Member Avatar for Lucaci Andrew
0
174
Member Avatar for LinaClark
Member Avatar for dilbert_here00

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).

Member Avatar for Gribouillis
0
470
Member Avatar for Toni Rahman
Member Avatar for Lucaci Andrew
-3
135
Member Avatar for selcabs

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 …

Member Avatar for Lucaci Andrew
0
106
Member Avatar for ahpple.gonzales

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.

Member Avatar for PrimePackster
0
238
Member Avatar for marnun

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 …

Member Avatar for marnun
0
516
Member Avatar for ImZick

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).

Member Avatar for kemcar
1
351
Member Avatar for peymankop

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: …

Member Avatar for Lucaci Andrew
0
129
Member Avatar for amit43

`cin` waits till the user inserts something into the stream, and after that it takes into consideration the `'\n'`

Member Avatar for Lucaci Andrew
0
81
Member Avatar for ssh9411

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 …

Member Avatar for Lucaci Andrew
0
160
Member Avatar for Alexkid

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; …

Member Avatar for deceptikon
0
4K
Member Avatar for bibiki

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.

Member Avatar for bibiki
0
145
Member Avatar for sumair khaliq
Re: Game

> 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 …

Member Avatar for Lucaci Andrew
0
141
Member Avatar for arnabjonty

Have a look at this post: [Click Here](http://www.daniweb.com/members/938124/Lucaci-Andrew/posts/5#post1888886)

Member Avatar for Lucaci Andrew
0
156
Member Avatar for anukavi

Maybe this could help you: [Click Here](http://stackoverflow.com/questions/9847441/setting-socket-timeout?answertab=votes#tab-top)

Member Avatar for anukavi
0
232
Member Avatar for new_developer

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, …

Member Avatar for Ancient Dragon
0
612
Member Avatar for silvercats

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 …

Member Avatar for NP-complete
0
197
Member Avatar for Coach_Nate

**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 …

Member Avatar for rubberman
0
261
Member Avatar for ayieye

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 …

Member Avatar for ninidesobra
1
189
Member Avatar for nitin1

How can you celebrate it? By taking a picture of that moment, at the right time, so that you can always remember it. ![IMG_1406](/attachments/large/3/IMG_1406.PNG "IMG_1406")

Member Avatar for nitin1
0
170
Member Avatar for M4ver1k

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> …

Member Avatar for M4ver1k
0
276
Member Avatar for thePAkid

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 …

Member Avatar for thePAkid
0
247
Member Avatar for TheBrick

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: ![grid-form.layout_](/attachments/large/3/grid-form.layout_.jpg "grid-form.layout_")

Member Avatar for TheBrick
0
241
Member Avatar for pjh-10

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.

Member Avatar for pjh-10
0
166
Member Avatar for nitin1

`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 …

Member Avatar for ravenous
0
144
Member Avatar for loldafuq

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 …

Member Avatar for Lucaci Andrew
1
1K
Member Avatar for marnun

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<<" "; …

Member Avatar for marnun
0
267
Member Avatar for MrBoye

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 …

Member Avatar for Lucaci Andrew
0
266
Member Avatar for munchlaxxx

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.

Member Avatar for Gonbe
0
2K
Member Avatar for NewUser22

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/). …

Member Avatar for Ancient Dragon
0
303
Member Avatar for marnun

> 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 …

Member Avatar for marnun
0
280
Member Avatar for restrictment

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.

Member Avatar for mike_2000_17
0
143
Member Avatar for pars99

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; }

Member Avatar for deceptikon
0
202
Member Avatar for serita.v.campbell

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 …

Member Avatar for Gonbe
0
208
Member Avatar for CHOCHOCHO

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, …

Member Avatar for Lucaci Andrew
0
373
Member Avatar for hasan101002

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, …

Member Avatar for hasan101002
0
405
Member Avatar for Lucaci Andrew

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?

Member Avatar for tech-ultrasonic
0
220
Member Avatar for milan2011

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.

Member Avatar for jrobertomar
0
2K
Member Avatar for Delightfully

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): …

Member Avatar for Lucaci Andrew
0
312
Member Avatar for thinkaboutyoueveryday

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 …

Member Avatar for thinkaboutyoueveryday
0
227
Member Avatar for subi09

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 …

Member Avatar for subi09
0
228
Member Avatar for rodrigo.l.salazar.14

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.

Member Avatar for Ancient Dragon
0
163
Member Avatar for marnun

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 …

Member Avatar for marnun
0
1K
Member Avatar for Hey90

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.

Member Avatar for Hey90
0
187
Member Avatar for steadi

**@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, …

Member Avatar for Lucaci Andrew
0
357
Member Avatar for arohideep13

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 …

Member Avatar for annajazz
0
170

The End.