97 Posted Topics
Re: [QUOTE=Phinisher;1453521]Unfortunately, that didn't work either. I understand getline, but may I ask how it is more efficient in the case of words? Wouldn't I still have to parse through each character in search of whitespace to determine a word? Could you give me a quick example, because I don't feel … | |
Re: Where have you defined the overloaded operator << ? | |
Re: There are some errors. The outer while loop ... [CODE]while (!infile.eof() { . . }[/CODE] will iterate through all the lines of your file. So the values of max, min and sum after the loop will be from the numbers of last line. You lost all the max, min and … | |
Re: The size member of class arrayListType is not getting any value and because of that list is not getting allocated. | |
Re: In show(), use a loop to traverse through the list till [CODE=C++]info->next!=NULL[/CODE] and increment info every time to point to the next node. In your code, you are not progressing through the list. | |
Re: Is this the complete code? Where are the variable declarations? | |
Re: The problem with the code above is the class GradeBook is getting declared twice. Once in the header file and once in your code. So when you remove the header file "GradeBook.h", the code compiles properly. And about your query of programing with header files. Dividing programs into files makes … | |
Re: Seems like you would like to overload << operator for your generic class pair2. You have not declared the overloaded operator function in your class and then you are defining it outside the class. Either define it inside class or declare it inside class and then define it outside. | |
Re: The problem is function declarations, you have declared both functions to take 0 arguments - [CODE]void getJudgeData(); void calcScore();[/CODE] Correct them and it should work. And using system("pause") is not good. | |
Re: You cannot use a void returning function with cout. Since you are outputting something on screen using displayObject(), why not just call it separately. Something like ... [CODE]GradeBook myObject( "You got Owned, g++ won't compile" ); cout << "myObject initialized\n"; myObject.displayObject(); cout<<endl;[/CODE] | |
Re: You need to have a global main too. [CODE]::main();[/CODE] And please use code tags around your code, it helps those who wants to help you :) | |
Re: The problem is function declaration. You have declared the functions to be accepting a char, instead of a char* though you have defined them properly. Correct the function declarations and it should work. | |
Re: In Student.h, function declaration of setStudent takes an integer array or integer pointer as argument. [CODE]void setStudent(string idIn, string fNameIn, string lNameIn,int scoreIn[]);[/CODE] But while calling it on line 39 in your code or line 40 here ... [CODE]student[numOfStu].setStudent(id, fName, lName, score[SCORE]);[/CODE] you are actually passing an integer in place … | |
Re: This won't compile because function x is having two overloaded versions with same signature - [CODE]void x(char)[/CODE] It should produce an error "Function Re-Declared" .. something like that. | |
Re: When the user enters the number wrong 10 times, xxx becomes equal to 0. And then this code [code=c++] if (xxx==0) goto son; [/code] causes it to exit. Modify the tekrar function, so that it resets xxx. It asks the user if he would like to play more but doesn't … | |
Re: Please use code tags. The line [code] cin>>next; [/code] takes input from the user for the number of eggs and then adds it to total. The while loop continues taking the number of eggs in each nest till the user enters any negative number. | |
Re: [QUOTE=;][/QUOTE] As per my understanding of your problem, you need to declare car as a global variable and you'll be able to access it from everywhere without redeclaration. Also, you have not defined "option" variable used on line 16 and 18. On line 16, you are treating as a simple … | |
Re: [QUOTE=;][/QUOTE] Please correct the code tags. >> operator reads until the first whitespace character. So when you are reading the file which has "burcin eric 783389" with the following code [code=C++] f>>name1>>numb1; [/code] name1 gets burcin and numb1 gets erec. | |
Re: Hint : You are adding elements to tree's root only. And what's the purpose of line 97. [code=C++] array[index]; [/code] | |
| |
Re: In reduce function, you are equating x and y to local uninitialized variables a and b which should give errors. Set function looks ok, but in get you are returning parameter values instead of actual numerator and denominator values. I have not checked the logic of your program. | |
Re: First thing, don't use system("pause"). Why sum1==sum, the question says when the investment of Celio exceeds Daphne's. Also in loop, you are just incrementing sum1 and sum... do you think that's correct? | |
Re: Declare find() before main() and it should work. [CODE]bool find(int&,int)[/CODE] | |
Re: I don't think it'll work because ifstream won't work with File pointer i.e ifstream parameter won't accept a File Pointer. | |
Re: cout<<"String"; The "String" should start and end on same line in the editor or you can extend it like .. cout<<"Str" <<"ing"; | |
Re: I tried compiling the header "Globals.h" and the first cpp defining GlobalVars(). It didn't give any error. | |
Re: Is it that you want the menu to be displayed according to the Account ID? Can you please detail a little more about your problem. | |
Re: Don't use System("pause"), instead as LordNemrod suggested use cin.get(). | |
Re: @Ancient Dragon - His Bubble sort looping looks fine. | |
Re: But, i think a doc file is different form a simple text file so this should not work. | |
Re: Try using the complete path withing double quotes ... | |
Re: You can't get something from an output stream ... Do you want to read a single character at a time from a file, crypt it and then put it back on a new file? | |
Question by ~s.o.s~ Write a program which will perform the job of moving the file from one location to another. The source and destination path will be entered by the user. Perform the required error checking and handle the exceptions accordingly. (Intermediate) [code=c++]#include<fstream> #include<iostream> #include<cstdio> using namespace std; int main(){ … | |
Re: In for loop, you used condition "dword[a] > 0" ? What you meant by that? You using an old compiler? inlcuding <iostream.h> You should not use goto, it creates bad code instead use do while. | |
Re: I didn't got you completely. Why to use Find and replace? For Encryption : Open the file, read the lines in a string, call encrypt and then store back. For Decryption : Open the file, read the lines in a string, call decrypt and then store back. Is that what … | |
Re: [code]s=temp[/code] s a char array & temp a strng object. [code]return s[/code] What's the return type of operator +=? Is is char*? | |
Practise problem by ~s.o.s~ Q. Write a program which performs addition, subtraction, multiplication of matrices. The dimensions of both the matrices would be specified by the user (dynamic memory allocation required). Use of structure or a class to define the matrix would be a good idea. (Expert) [CODE]#include<iostream> using namespace … | |
Re: Put a check on the input numbers before operating on them. | |
Re: For prime function, have a look at this thread - [url]http://www.daniweb.com/forums/thread143933.html[/url] . And for random function, have a look at this thread - [url]http://www.daniweb.com/forums/thread1769.html[/url] | |
Re: I think you can declare and intilialize steps after the function "processTurtleMoves" declaration. [code=c++] void TurtleGraphics::processTurtleMoves( const int commands[] ) { int steps=0; .... .. .. .... .. .. } [/code] This should solve the problem. And as WaltP said, use a prefix form rather than a postfix one. | |
Re: Function call should be like this [CODE] func(array_name); //where array_name is the name of your array. [/CODE] You should pass the array without any index, because passing with an index makes the value at that index to be passed as argument not the array. And you second question's answer - … | |
[URL="http://www.daniweb.com/forums/post303743-1.html"]Q.Write a program which will print all the pairs of prime numbers whose sum equals the number entered by the user. ( suggested by Aniseed ) (Intermediate) [/URL] [code=C++] #include<iostream.h> #include<conio.h> #include<math.h> int prime(int); void main() { int i,j,c1,c2,num,f1,f2; clrscr(); cout<<"Enter the number-"; cin>>num; for(i=2,j=num-2;i<=num/2;i++,j--) { f1=prime(i); if(f1) { f2=prime(j); … | |
Re: [QUOTE=BradenMurphy;685236]system("pause"); return 0; use that at the end of ur main method should work:)[/QUOTE] I think using system("pause"); is not recommended. | |
This is strstr() function made by me as given in the practice problem. [code=c++] char *cstrstr(char s[],char ss[]) { int l1,l2,i,j,k,flag=0; char *p=NULL; l1=strlen(s); l2=strlen(ss); for(i=0;i<l1;i++) { //cout<<"i:"<<i; p=&s[i]; if(ss[0]==s[i]) { for(k=i,j=0;j<l2;j++,k++) { //cout<<"j:"<<j<<"k:"<<k; if(ss[j]==s[k]) { flag=1; continue; } else { flag=0; break; } } } if(flag) return p; } … |
The End.