581 Posted Topics
Re: Well the = operator is actually pointing the var[x][y] to the variable inp I think that you should replace the = operator with [code=cplusplus] for(int a=0;a<=len;a++) var[x][y][a]=inp[a]; [/code] I guess that would make it work as we are asigning the created array with a characters. | |
Re: [QUOTE=Freaky_Chris;802669]The other option would be to close the file stream and then re-open, btw be sure to check that you actually need to read the file stream twice, rather than loading it contence into some data structure then reading that again. Just pointing that out because file access is slow … | |
Re: Well post in your code again. And secondly. I dont see the variable "info" initialized in the code. Just check that out. | |
Re: Well I dont think it would work out. Basically constructors should be members of that particular class or if you design it explicitly it will become a function with the same name of the class and will produce out an error. If you wish to make the above methods work … | |
Re: Well if the total content is in a string or in a file i guess it wont be much trouble reading them in. For the user. You can just search for a space in the string ' ' and then consider the next word as the user. And for the … | |
Re: Well if you have idea about math, You can write the implementation itself by using the angles and the functions "sin , cos , tan etc. " Provided in the c++ math library. And if you wish to get yourself a algorithm i suggest you try googling it up. | |
Re: Well i guess now you could use another variable to count how many times a particular number is repeated in the data set and then could get the percentage of the occurence of that particular number . You should however post your tries on doing this and we can help … | |
Re: Well i guess you can read each line of the file with getline functions and then search for each of your words inside the string. If it is found. you can use the erase function to remove that particular part of the string and then you can now insert your … | |
Re: Well What exactly does Spiral mean? Secondly could you just illustrate what is the desired output your code like you did with the mspaint example. | |
Re: [code=c++] std::clock_t start; std::clock_t end; double diff; int i; int a = 2; int b= 3; bool ba = true; bool bb = false; double da = 2.0; double db = 3.0; double cc; string input = ""; printf("Start\n"); start = std::clock(); for (i=0;i<4000000000;i++) { if (da==db) //CHANEGS MADE HERE … | |
Re: [code] test::test() { struct deneme denemeler[5] = {{1,2},{3,4},{5,6},{7,8},{9,10}}; } [/code] I think that the above function is defining a new denemeler of deneme type and then as the constructor ends it gets destroyed. Hence you loose those values. After that your actual denemeler member doesnt contain any value. So hence … | |
Re: [QUOTE=Freaky_Chris;790163]all of the lines to your if statement should be wrapped in {}. Also using cin>> is a step backwards from getline() you should read the stick "How do I clear the imput buffer?" Chris[/QUOTE] Along with the above you should also try to separate your code with functions. And … | |
Re: Well thats quite simple. You should try reversing the string also. However for the above encryption Take in the string. Then you should initialise another string Take a char from the first string and then store it into the second one. Then add your '0' To the string and again … | |
Re: Secondly. If the day calculator function works. You can use the same thing to return yesterday and tommorow by using daycalculator with the inputs of (1 and ,-1) right | |
Re: Well i personally didnt understand the char * cast that you put in the write. I would recommend that you should write in a << operator for your class . Such that it sends in the data as it is required. [code] int Student::operator << (&ofstream out) { out<<FullName<<CompleteAddress<<Gender<<Age<<LivesInASingleParentHome<<endl; } … | |
Re: Well i think that you should use getline(); and then get the input onto a stringstream or a string and then follow onto the next thing. with the string or stringstream itself. Other than that i dont know a way of finding the end of the line. Because i am … | |
Re: [QUOTE=Murtan;782124]Add some debug... Does [icode]list[cnt] = (int)inputVal.c_str();[/icode] get you the numeric value you entered, or the address of the string?[/QUOTE] Well i dont think the int cast would do the trick. You can do two things for this 1 [code] list[cnt]=atoi(inputVal.c_str(); [/code] or 2 [code] istringstream s(inputVal); s>>list[cnt]; [/code] I … | |
Re: Well i think that you should post your code until where you have worked on. | |
Re: Well for the starting day. i guess you can do this. First find this [code] int a = daysinwholeyearssince1800%7 [/code] According to this site [url]http://www.timeanddate.com/calendar/?year=1800[/url] First january 1800 was a Wednesday .. So if [code] string days[]={sun,mon,tue,wed,thurs,fri,sat}; //Then you can get the starting day with this int s =3+a; //the … | |
Re: And as far as testing is concerned. Each row and column should have a the numbers 1 to 9 in them and they should not repeat. So i guess You can do something like this. [code] for (int j=0;j<9;j++) { int total=0; for (int 1=0;1<9;i++) { total+=sudoku[j][i] } if(total!=45) { … | |
Re: I dont get it, Your template destructor doesnt have anything to delete when the size of the class is 0, So i guess you should just implement to apply to an empty stack too. if *pointer==null;//maybe; | |
Re: Dude show us the code that you have worked on so that we can help. We donot do others homework. | |
Re: Well i dont think arrays can be initialised with variables. i think vectors are the suitable task for the job. | |
Re: Seems to be a big post!!! Man, I guess you just have copy, pasted all the questions from your assignment. I reccomend that you read this post. [url]http://www.daniweb.com/forums/announcement8-2.html[/url] | |
Re: I am not sure, but i think you should try including iostream too. | |
Re: [url]http://www.eternallyconfuzzled.com/tuts/languages/jsw_tut_pointers.aspx[/url] Here is another llink that would help. | |
Re: Well You should use files to store data and get back data in the beggining stages. filestreams would help you out with that. Try googling out filestreams with c++ for a tutorial. | |
Re: Well in your source code, what does i=q,u mean? it isnt a valid statement. You can try doing this. [code=cplusplus] #include <iostream> using namespace std; int main() { int q; int sum = 0; int num; cout << " Please enter a positive even interger "; cin >> num; if … | |
Re: You can keep a new variable for every item. Namely price. int price =10; and a function like [code] void buy() { if(money<price) { cout<<"Not Enough Money"; else { //Code to add in another .... goes in here } } [/code] This is an example You should try to get … | |
Re: Subscription operator can be overloaded. it involves using New and a destructor I think. | |
Re: Well Its very easy, If you know how switch statements work. [code] char x; cin>>x; switch (x) { case: 'a' cout<<"x==a"; break; case: 'b' cout<<"x==b"; break; default: cout<<"no match found"; break; [/code] This is a small example of how you can use switch statements hope it helps. | |
Re: I am not sure about this , But Why returning (*this)? In your = operator. | |
Re: Well does this really convert the char to string? [code] int convert(char time[5]) { int time_mins; int int_time[4]; int_time[0]=time[0] - '0'; int_time[1]=time[1] - '0'; int_time[2]=time[2] - '0'; int_time[3]=time[3] - '0'; time_mins = int_time[0] * 1000 + int_time[1] * 100 + int_time[2] * 10 + int_time[3]; return time_mins; } [/code] You … | |
Re: Well I see that you will need to delete all the members until you are left with one. So you will need to do this. [code] #include <iostream> #include <list> using namespace std; int main() { int n;//number of soldiers int k;//number skipped between cout << "Welcome to The Josephus … | |
Re: We would like it if you could post in your attempt and then we will sort it out to show your mistakes. | |
Re: I think your game should run until the user runs out of money!! So You should be having 2 while loops. [code=cplusplus] while((bank!=0)&&(play=='y')) { noofGuesses=0; random = genRandom(); while ((noOfGuesses < 10)) { cin >> guess; noOfGuesses++; c = checkGuess (guess); if (c == 0) { total = bank + … | |
Re: Well this is nothing but an arithematic progression. Well the first element is 3 and the second element is ((3x1)+0)=3 again the next element is ((3x2)+1)=7 and so on. So you will just need to take in the first element as a ; Then to get the first element multiply....... … | |
Hello Everyone, I have my Windows Xp operating system with perntium 4 in my Pc with 20 gb hardisk installed. So i divided the space into 2 partitions , C: with 8 GB and D with 11 GB and the other was just unformatted. It was running Fine. But suddenly … | |
Re: Hey I donot understand Why you actually need the second loop. I prefer to do this 1)initialise all elements of your subarrays to '0' 2)Remove the second for loop 3)After finding the limit in which the value can be assigned in , Search for a zero in the sub array … | |
Re: >Please Provide The Simplest Code. Well wont it be simple If You create a function to interchange the first and last char and then the last but one and second character and so on.... This should be done until They Come to the middle of the word. Try Implementing a … | |
Re: Well i dont get it , You are given two Binomails as input and then you are required to split them .. This is very simple. I GUESS you could just search for "(" start and ")" and give out the value in between as a factor. Unless You have … | |
Re: [code] void Prt_Gradebook (string names[], int score[][3]) { for (int i = 0; i < 5; i++) { cout<<names[i]<<" "; int sum = 0;//Changed It to Here. for (int j = 0; j < 3; j++) { cout<<score[i][j]<<" "; sum+=score[i][j]; } cout<<sum/3; cout<<endl; } } [/code] How about this ? … | |
Re: [QUOTE=JackDurden;707731]neither of your answers worked[/QUOTE] No they seem to work out fine. Its just that the template node should be declared before template snake does. Just by doing that. the second example works. [code=cplusplus] #include <iostream> #include <stddef.h> using namespace std; template<class T> struct node { T data; node *next; … | |
Re: Hey, Are you sure that the file is being opened? Because Your Code Doesnt Test whether it has opened it [code] if (myfile.is_open()) { /* ok, proceed with output */ } [/code] You should have an if statement like the above to know that you have opened the file successfully. | |
Re: Try Initialising Totalrooms and Total Occupied to zero first and then run the code. | |
Re: I think you should understand exactly on how these functions are called and executed and choose a spot Yourself. And as far as the time limit is considered. You should multithread the program , I dont see anything else capable to do so. | |
Re: [url]http://www.daniweb.com/forums/thread70096.html[/url] There are a list of good books. Feel free to purchase and study.. | |
Re: [url]http://www.daniweb.com/forums/thread42722.html[/url] I think this should help you a bit . After finding all the files You can just copy and paste those files into a different directory. | |
[code=cplusplus] string countx(string sky) { int count=0; for(int x=0;x<=sky.size();x++) { if(sky[x]=='x') { sky.erase(x); ++count; } } stringstream ins; string bang; // Declare an input string stream. cout<<"count " <<count; ins << count; bang = ins.str(); sky=sky+"x^"+ bang; cout<<"Sky == "<<sky<<"\n"; return sky; } [/code] Writing a function that will take … |
The End.