5,676 Posted Topics
Re: #1) What [B]zeroliken[/B] said #2) It's C++. Why are you using the terrible and dangerous [B]C[/B] function [iCODE]gets()[/iCODE]? Use [iCODE]getline()[/iCODE]. #3) [ICODE]cin[/ICODE] is your problem. Reading an [I]int[/I] leaves the NEWLINE in the input buffer. The solution has been explained many many times on this site -- do a search. | |
Re: [QUOTE=Torf;]Hello, I do not understand the following parts in bold - how it works, what is is for..etc. I'm not following the book's explanation..[/quote] It called a prototype. If you [I]use[/I] the function (line 17) before you [I]define[/I] the function (line 30) the compiler does not understand line 17. Therefore, … | |
Re: Output your values at key points in your code to 1) make sure the variables contain the values they should 2) make sure the IF is processing the correct code | |
Re: It's because the input you are probably using, by definition, stops inputting at a SPACE. Your error is not in the code posted. | |
Re: You've been waiting 4 years to get back to this program? No wait... First post -- resurrecting an old thread -- for no reason other than stating [I]something[/I] doesn't work, but not explaining [I]what[/I] doesn't work. [B]FAIL!![/B] Start your own thread and ask a [B]real[/B] question. | |
Re: [QUOTE=theCompiler;]can someone please tell me how am i suppose to start my program ?[/quote] Open the editor in your IDE Type in the program you designed to solve the problem. That's how to start your program. [QUOTE=theCompiler;]i have 20 integers (1-20) the user will input what number should start and … | |
Re: Create a function to read the numbers. Search this site for ways to read characters in number inputs. It's been answered at least once a month for years. | |
Re: No, it's because of undefined behavior. [url=http://c-faq.com/expr/evalorder2.html]See this[/url] | |
Re: Try removing the comment indicators at the beginning and end of the code. It might compile better. Help in what? You have to ask a question in order to get help. | |
Re: Do any of your strings, including [I]engine[/I], have a trailing newline? Add output statements at key points in the program to display important values. Like [I]first, last, middle, string[middle][/I]. | |
Re: 4 resurrections... Great. [QUOTE=mharicz;]looping statements if n=5, output ******** ****** **** *** * plz answer :([/QUOTE] ... and with a [I]gimme the code[/I] question -- how lazy. Closed. | |
Re: Search the string for the _ and replace it with whatever you want. | |
Re: We can't help you overcome any problems when we have no idea what the problems are. So far you have given us no information and you have not asked any questions. (adding a ? to the end of a statement does not make it a question) | |
Re: [b][boilerplate_help_info][/b][code] Posting requests for help must be well thought out if you want help quickly and correctly. Your post did not meet the criteria for quality help. You may get some posts, but are they going to be useful? Check your post with these checkpoints - what is it [i]you[/i] … | |
Re: [QUOTE=sinatra87;]Is there a simple way to catch the char input and ask the user to fix his choice, similar to the way my program handles a user entering a [I]number[/I] that isn't in the menu?[/quote] Read all your inputs as strings. Test the string for all digits. If correct, convert … | |
Re: [QUOTE=roverphoenix;]feel free to edit or modify the code, its been a long time since I have played around with this code :)[/QUOTE] Then you should have played with it before posting. [ICODE]goto[/ICODE] and [ICODE]gets()[/ICODE] are extremely poor techniques in coding. And for a professional? At M$? No wonder updates are … | |
Re: [QUOTE=DeanMSands3;]I can think of two ways to do this. (Also, get rid of the return j. It returns from the main function and exits the program. Get rid of the printf(j) at the bottom. Why do you have it?)[/quote] There's a third possibility that makes even more sense... [QUOTE=DeanMSands3;][B]First[/B]: using … | |
Re: Add [iCODE]chr(34)[/iCODE] to each side of the string. 34 is the value for double quote. | |
Re: 1) use an array to add up the numbers ([iCODE]int roll[6][/iCODE]) 2) calculate your random [I]answer[/I] (do not add 1 giving 0 => 5) 3) use [I]answer[/I] as an index into [I]roll[][/I] and increment ([iCODE]roll[answer]++;[/iCODE]) At the end of the loop, [I]roll[3][/I] will contain the number of 3's "rolled". | |
Re: [QUOTE=chibex64;1620883]Can't remember 'BIDMAS' if at all i know it. All i know is 'BODMAS' [and the others][/QUOTE] Never hear of any of them. The only acronyms I remember is "Every Good Boy Does Fine" and "FACE". They are very mathematical, too. By the way, it's [B]math[/B], not [B]math[I]s[/I][/B]. | |
Re: You could PM the commenter. But be careful. Don't do it too often. | |
Re: Standard C cannot do what you want. Input is only accepted using the ENTER key. You have to go into non-standard specialized code that most compilers do not contain. | |
Re: We can't see your screen to see what the code looks like now. | |
Re: [QUOTE=DJSAN10;]Just another suggestion how you could do it.. (No need of using do while) [CODE] while(1) { if(...) { } else if(...) { } else if(...) { } else break; }[/CODE][/QUOTE] This is a terrible suggestion. A while loop is designed to exit when a condition is met, which is … | |
Re: With what? Formatting? OK, [url=http://www.gidnetwork.com/b-38.html]here[/url]. Stopping the program from inside the function? Don't. It's a bad practice. Return a value that indicates what to do in [iCODE]main()[/iCODE] | |
Re: [QUOTE=subith86;]Use getch() function defined in conio.h thereby you can avoid using scanf() to hold the output screen.[/quote] Very bad suggestion. [ICODE]getch()[/ICODE] is 1) not portable 2) not Standard C 3) defined in very few compilers The appropriate function to use is [ICODE]getchar()[/ICODE] because it is 1) portable 2) Standard C … | |
Re: Don't use [iCODE]gets()[/iCODE] [url=http://www.gidnetwork.com/b-56.html]Here's why[/url]. What he's saying is 1) Input the information as a string with [CODE]fgets()[/CODE] 2) Test each character to make sure it's all digits or 'EXIT' 3) If all digits, convert to integer with [CODE]atoi()[/CODE] [QUOTE=Ararat;]can you maybe translate that into a code since I don't … | |
Re: Try [CODE] cout<<"Name:"<<endl; std::getline(std::cin, name); cout<<"Phone:"<<endl; std::getline(std::cin, phone); [/CODE] Mixing line inputs ([I]fgets/getline[/I]) with [I]cin[/I] is causing problems because they both do things differently. [I]cin[/I] is leaving the input stream dirty (stuff left in the buffer you aren't expecting). | |
Re: Is there a NEW-LINE after the last }? Sometimes that causes the error. | |
Re: [QUOTE=DanielMilstein;]This is again one of the stupid ways of spammers out there who want nothing but money from you, when you will contact them they will have some false sob stories with some pictures that are very difficult for a normal person to view..[/QUOTE] From experience, I assume? :icon_twisted: | |
Re: No. In order to read the 5 you have to hit ENTER. | |
Re: [QUOTE=Dcurvez;1732123]wonder if there is a way to just not allow certain words in the subject line? (help, urgent, ect..) im also not versed on websites (barely understanding vb) but, just an idea is all (and not really sure if its a good one LOL)[/QUOTE] What part of [QUOTE=cscgal;1731278]Hold your suggestions … ![]() | |
Re: Try Googling for [I]permutations[/I] so you can learn the basic algorithms. | |
Re: Lots of problems in this code... [CODE]#include<stdio.h> #include<conio.h> // unnecessary, non-standard -- should not be used #include<stdlib.h> #include<string.h> #include<time.h> void main() // MAIN is not and never has been a 'void' -- see below { int i[100]; // create an array from i[0] to i[99] int j[100]; int k; int … | |
Re: My main problem is your lack of consistent formatting and really deep indents. It makes the code very difficult to follow. [url=http://www.gidnetwork.com/b-38.html]See this[/url] for better formatting techniques. | |
Re: [QUOTE=Raymond10;]Sorry but I'm not very good at explaining...[/QUOTE] Then why don't you post an exact example of what you want the output to look like? It's always easier to [I]show[/I] than [I]explain[/I], although both are important. | |
Re: Have you designed the program yet, or are you just tossing code around to see it it works? This is the type or program you need to plan before starting to code. Design a [I]roadmap[/I] of what needs to happen 1) when you find a directory 2) when you start … | |
Re: In [iCODE]main()[/iCODE] you use 2 to convert to binary, correct? What would you use for hex? | |
Re: [QUOTE=mits28;]can you please tell me some books and sites for reference...i want to learn HTML and web designing..from basics to higher level..so that i could design website[/QUOTE] [url=http://lmgtfy.com/?q=html+reference]Try This[/url] | |
Re: [QUOTE=Webmastergrace;]let me know what flush(stdin) describe. is ti any kind of function or something else................... try resolve my problem[/QUOTE] [ICODE]flush(stdin)[/ICODE] describes something that knowledgeable programmers would never use. [url=http://www.gidnetwork.com/b-57.html]See this[/url] | |
Re: They need help for their homework or project and waiting a few days is a good thing? How long would [I]you[/I] wait when you need help with a problem? I'd expect [I]everyone[/I] would just go somewhere else. | |
Re: Don't know. Have you tested the [I]hidemouse()[/I] function outside of this program? | |
Re: What is the importance of STEAK even we r with CHICKEN today? | |
Re: Just look in the .lnk file or right-click and select [I]Properties[/I]. Then copy the location right out of the link file and put it into your 'launch' program. Then you don't need all this Rube Goldberg crap. An .exe to call a .bat file to call a .lnk file to … | |
![]() | Re: [QUOTE=Smartflight;]The aim is simple: Input a string from the user, input a word that is to be searched in the string, and return "Found" or "Not found" I have worked down the following code, and it works. [CODE]#include <iostream.h> #include <stdio.h> #include <string.h> void main () { char para[200], word[20]; … ![]() |
Re: Maybe you should read this Code Snippet then, as well as the posts. Follow the code using pencil and paper to understand code in general. | |
Re: [QUOTE=DalekThay;]Can anyone explain me how to find a point on circumference. The data i have is radius and the coordinates of circle center. I tried to get it by using (x-a)^2+(y-b)^2= r^2 formula but i get stuck. I'm not asking for solution but for explanation.[/QUOTE] Getting "stuck" tells us nothing. … | |
Re: [url=http://www.gidnetwork.com/b-60.html]See this[/url] and [url=http://www.gidnetwork.com/b-43.html]this[/url]. |
The End.