406 Posted Topics
Re: What first person has said is right about the wrapping but the example given is wrong as it quits the loop on every input 0 or 1(at least according to gcc 4.3). the error is in the line: [code=c++]char quit = false;[/code] You cannot use a character variable to hold … | |
Re: [B]Definitely no need of looping required.Its a simple four step procedure.[/B] [B]1 )[/B] Read the entire line into the character array say str. [B]2 )[/B] Check if string length of str is greater than 22 or not. [B]3 )[/B] If no then [icode]cout << str ;[/icode]. [B]4 )[/B] If yes … | |
Re: Show your work... We will surely help you. | |
Re: Never done it before ? Very good try it now !!! Only then you will learn... Well in C you would do something like : [code=c++] FILE *f; char str[100],*str1="file",*str2=".txt"; //You have count and file<count> is the file you want to open sprintf(str,"%s%d%s",str1,count,str2); f=fopen(str,"rw+"); //Go on with your writing work … | |
Re: Ya lots of ideas... but cant express it until you show your code... | |
Re: There is nothing C++ in this code apart from "using namespace std","cout","bool". You aren't using the isnum function at all as its not used in any decision statements even when it returns true and false. Your isnum function itself id flawed. [QUOTE] if(!isdigit(*str)) cout << "Invalid format" << endl; [COLOR="Red"] … | |
Re: You are using integers to store the factorial of a number and obviously 13! 14! 15! will go out of integer range. It definitely overflows and that is the reason you are getting erroneous outputs. try changing the variables to long int or double and you will get the desired … | |
Re: [B]@sparksterz[/B] : No you should not use system("pause") to view the output.It has been discussed here a lot number of times. You can use cin.get() instead and it too will work in the same way. [B]@yuha[/B] : Not one there are several things wrong with this code. [B]1) [/B]Usage of … | |
Re: Its no coding secret or something but a simple formula kind of thing here it is : For[B][U] two[/U][/B] numbers: [B]max( a , b ) = ( a + b + abs( a - b ) ) / 2[/B] For[B] [U]three[/U][/B] numbers it is: [B]max( a , b , c … | |
Re: Ya Sure... Our [B]Assignment Delivery Boy[/B] will come over to your house in another 30 minutes and deliver you the assignment along with the free things which we have offered.Please pay him the amount in cash.Good Day !!! | |
Re: Waltp and Campbel are right in their concepts but you can still decrease the numbers from which you divide. If the number you need to check is "num" then divide num with 2 and every odd number form 3 upto [ ( int ) sqrt ( num ) + 1 … | |
Re: You can take the player class as : [code=c++] class player{ private: string name; int goals_taken; // Keeps count of goals taken int shots_taken; // Keeps count of shots taken int num_streaks; // Keeps count of streaks int num_slumps; // Keeps count of slumps // Keeps count of matches continuous … | |
Re: They have mentioned everything so clearly... Use if else or if else ladder to find the ranges in which the given temperature falls and print accordingly... | |
Re: Whenever you define a string as [code=c++] char str[]="Hello\0MIster\0HowAre You?"; printf("%s",str); [/code] Every time the compiler stops outputing the characters of the string to the output console once it encounters a '\0' character.So even if you put '\0' character in place of ' ' character this won't do any good. … | |
Re: First thing I don't see the purpose of this program as to what it does or is intended to do and apart from it this isn't a psuedocode,this is a C++ code itself other than some erroneous brackets which you can obviously correct by finding a matching pair of brackets … | |
Re: Too many problems in your code as I see : [code=c++] string str[0]; int i=0; while(!myFile.eof()) { getline(myFile, str[i], '\n'); vec.push_back(i); } [/code] [B]line 1 :[/B] string str[0] will result in some unexpected value and not the string you want it to hold so change it to [icode]string str;[/icode] but … | |
Re: First of all your code here is incomplete and doesn't serve the purpose until further alterations. Second if you are sure of the three columns present then instead of ">>" getline with specific modifications to fetch the columns separately and store it in different arrays and then calculate their average. | |
Re: Thanks for posting your assignment/homework for us to work on.... But there is one tiny bit of problem... [B]1)[/B][COLOR="Red"]This isn't the JAVA forum.[/COLOR] [B]2)[/B][COLOR="Red"][B]We never do others homework we just help them to do it on their own.[/B][/COLOR] ACTUALLY TWO.... | |
Re: Just use srand() and rand() commands for more information and how to use them do research on them. | |
Re: Please put in the code and mention the area in which you are facing troubles and then ask us... In this way we can help you better... | |
Re: Where is your program by the way...??? | |
Re: [B][U]Backing up what niek_e said :[/U][/B] You have used [icode]c[i].GetName()[/icode] in your for loop, you can use c[i].<function name> only if the classes are declared as Customer c[3] or something else you should use the functions as c1.<function>(); c2.<function>(); c3.<function>(); separately as c1.function(); is completely different from c[1].function(); Ok and … | |
Re: Are you allocating the memory for the stack dynamically...? | |
Re: Whenever you initialise an array partially,the un-initialised part of the array are initialised to zero's automatically.Thats the only thing which happens and as per my knowledge there is no such symbol which would function as you suggested. For it there are two ways, one is you initialising every block value … | |
Re: Here are your Errors... [B]Err 1:[/B] Line 67 : [code=c++]scanf("%d", operation2);[/code] It should be [code=c++]scanf("%c", &operation2);[/code] [B]Err 2:[/B] Your macros are completely useless in this case.Even though you can change them to correct the mistake I would suggest an alternate way. [code=c++] scanf("%c", operation2); /* uss a switch case structure … | |
Re: Here's your second fastest reply........zoooooooooom..... here it comes... [B] Try it your self[/B]... and post your code here with the problems you are facing then we will be more than happy to help... | |
Re: [B]Make use of code tags else no one would even care to look at your code.If you use them it would look like this.[/B] For more information look here [URL="http://www.daniweb.com/forums/misc-explaincode.html"]link[/URL] [code=c++] #include <stdio.h> int input_number(); int main(void) { int numbers[100]; int counter; int sum; int number_elements; printf("The number of elements … | |
Re: Your question is very vague... Firstly Identify the type of image file you want to open...Then upon it you need to know that how many bits represent a pixel in that format then your work is very easy. Just pick that many number of bytes and match it with the … | |
Re: Hey this is a C question and you have posted it in a C++ forum. If I am not wrong then you don't want to accept numbers 5 5.5 -5.5 -5 and similar... So you can do this : [code=c++] double rem; rem=fmod(l,5.0); if(rem > 0) printf("Not an error"); else … | |
Re: Ya lots of people can tell once you really start doing something... | |
Re: I wan to say two things : [B]1[/B]) [COLOR="Red"]Read the forum rules...And let the thread head specify the topic rather than "Oh please help me.." or "Do my homework for free you dumbo's..." [/COLOR] [B]2)[/B]The question is quite clear try something and then come back. Even the looping information is … | |
Re: Hey you are posting every problem related to this hangman here at daniweb.Try something on your own.You'll learn a lot. And indent the code properly so that its easy to read... [code=c++] void Hangman::blankSpaces() { cout << "Your word to guess: "; int k,i,flag,p; for (k=0; k<strsz; k++) { flag=0; … | |
Re: This is a very generic question which can only be solved by you depending on your interests. C and C++ help you a lot in system side programming. Java helps you by providing a lot of utilities for application development. Python is a very powerful language which will be the … | |
Re: Make use of the standard functions given to you,without using that you'll never be able to exploit C to its full potential. You can do this: 1) take the hex number as the input into a character array without the prefix "0x" or "0X" as : [code=c++] char arr[10]; cout<<"Enter … | |
Re: Your code has probelms in function Hangman::blankspaces(). In it you are matching every character of the chosen character with the last guessed character and printing _ or the character for the whole word every time. thats the reason it is showing only the last selected character's place values if any. … | |
Re: Why use a for loop and looping through every character when you have predefined functions for that...??? You are reading the inputs form a text file right,just do this : [code=c++] ifstream file; file.open(<your filename>); char str1[10],str2[10]; file.getline(str1,256,'+'); file.getline(str2,256,'\n'); [/code] Now you have the two values you wanted in str2 … | |
Re: [B]What Ancient Dragon has suggested is a wonderful suggestion[/b] try to implement it but it [b]is completely inconsiderate with the problem in your code...[/B] In your code : [code=c++] for (int i = MAX - 1; i >= 0; i--) cout << output[i] << endl; //Compiling error if (i % … | |
Re: [quote]cin >> sa; if (sa == NC) NC = "North carolina"; else if (sa == SC) SC = "South Carolina"; cout << "The State Abbreviation you entered stands for " << sa << endl; [/quote] Error lies here.You take sa as the input string and then you even match it … | |
Re: Well I am not able to get your problem exactly but from what I have got I think you can write a friend function which can read those arrays and write it conveniently to the place you want so that you have all the array values which is as good … | |
Re: You are talking about a text file access through C++ and you should know that for it there is no concept of line,its just a stream of characters and the compiler knows that it should print the characters following '\n' character in the next line. Using this '\n' as a … | |
Re: Ya I too feel this is TC that you are working on.So I would suggest this... [B]1)[/B] You can always play with the co-ordinates when working on TC, like usage of gotoxy( x , y ) To move to a particular part of the screen and then print the stuff … | |
Re: Hey tux that was the assignment given by4101 to you. Do it sincerely...You'll learn a lot ;) | |
Re: It must mean that [ICODE]quizMaster.isCorrectAnswer(answer)[/ICODE] is always returning 0 .Just check in that particular function for solving the problem. Its quite straight forward right. | |
Re: [B][U]Little corrections to both the posts given above with some information:[/U][/B] [B]@23.12.2012:[/B] Here [ICODE]s1+=8;[/ICODE] doesn't really help because ASCII value of 8 is [icode]'\b'[/icode] character the backspace character.And by executing the above statement with earlier string s1 which was "Hello World! I am" we get "Hello World! I am\b" as … | |
Re: Well here's a starter for you : Let the class be something like this ... [code=c++] class stack{ int arr[50]; //To create a stack of size 50 int top=-1; //Initial value for the variable holding the top position in the stack; public: int push(int x); //Function which takes x as … | |
Re: [QUOTE=Ancient Dragon;925177]Looks ok to me. The only problem I see is that >> operator will not allow the file name to contain spaces. [B]You need to use getlin() if you want spaces[/B]. Why do you think the code you posted does not work?[/QUOTE] Thats getline() what [B]Ancient Dragon[/B] wanted to … | |
Re: Well we will help you for sure.Here are a set of good books from which you can learn.[URL="http://www.daniweb.com/forums/thread70096.html"]<USEFUL BOOKS>[/URL]. Read all this write a program and then if you have problems come back with your code we will do more than just helping you.Till then enjoy your studies.You wont get … | |
Re: The thing you are forgetting is that the concept of lines appear only in case of display to the terminal or in general just the display.While storing there is nothing called a separate line,it is just signified by the '\n' character which tells the display program to start printing in … | |
Re: [QUOTE=jephthah;923987]i think these posts ought to be instantly deleted by moderators, along with a copy of a standard explanation auto-delivered to the poster's email. I can see why Narue has all but left daniweb ... because it's [I]this[/I] kind of non-stop crap just makes me want to flame the hell … |
The End.