5,676 Posted Topics
Re: [B]John[/B] is correct on both counts. Change that nested IF into a switch and it'll be easier to read. I see a [ICODE]while[/ICODE] statement in [ICODE]case 1:[/ICODE] -- what is that supposed to be doing? | |
Re: [QUOTE=demroth;546031]Ok, here is what I have now. I am still getting errors when it comes to calling the function and passing the values.[/QUOTE] Such as? :icon_rolleyes: Psychically debugging code is hit or miss proposition. Mostly miss. Unless you give us information, there's not much we can do... | |
Re: We don't give code as answers to questions. We help you with the code you write. So try it and reply with your attempt. | |
Re: And you should have read The Rules. PERIOD. Well, comma, actually. Are you asking us to supply a program for you or help you write something? Would an Excel Spreadsheet be enough, or do you need a program? | |
Re: Guys, guys, we're supposed to be 'experts' here! :D #1: You are using a [ICODE]for[/ICODE] loop but your exit criteria of the loop depends on [I]counter[/I] and [I]limit[/I]. Your instructions say "[I]when the user enters a negative number or zero[/I]" and [I]counter [/I]has no bearing on the exit. #2: After … | |
Re: [QUOTE=sfurlow2;546616](I'll accept any reasonable solution to handling the first two numbers)[/quote]So nice of you :icon_wink: [QUOTE=sfurlow2;546616]This isn't working for me, and I'm not sure how to fix it or how to get the average of only the last three inputted numbers.[/QUOTE] Is there something about explaining why you think it … | |
Re: also, look up [ICODE]>>[/ICODE] and see what it means. | |
Re: Since I've never heard of [I]Bingo/Chess[/I] and have no idea what that means, there's not much I can do from a logic standpoint. And since there is absolutely no [url=http://www.gidnetwork.com/b-38.html]formatting[/url] in your code, there is no way I can understand what you have written. Post enough information about your problem … | |
Re: First of all, don't use ICODE tags unless you want to show code inline with your message. Your code is not too bad, but here are some comments for you to think about: [CODE=c] if (input[b] >= 85) { hcnt = hcnt +1; // you can also use hcnt++; inp … | |
Re: [QUOTE=cscgal;546941]That's because when there is only one line, brackets are implied and therefore not needed. (Although I would recommend them, especially when starting out.)[/QUOTE] Completely agree! [I]Always [/I]use brackets within an [ICODE]if[/ICODE] statement [QUOTE=Lerner;546907]Welcome to Daniweb![/quote] Yeah, what he said! :) [QUOTE=Lerner;546907]The error message probably means that you should have … | |
Re: This is C code not C++. That's probably why he posted it in theC forum... :icon_wink: | |
Re: You need to look more closely at where your loop is. Your code: [code] input a number test your operator (it was never entered) process the operator start a loop input operator if operator is illegal output error else input number end loop ... [/code] You never test any operator … | |
Re: [CODE]#include "stub.h" int main() { int x = 0; int highest_pos = 0; int lowest_pos; int counter; int highest_neg; int lowest_neg; [/CODE] The values [I]lowest_pos, counter, highest_neg[/I], and [I]lowest_neg[/I] start with unknown values. They could be 0, or 165432343, or -8554545487. You need to initialize them to some appropriate value. … | |
Re: Well, it's not a placeholder. You are defining arrays with no rows and no columns. There is no place for data. So once you try to put anything in your arrays, you overwrite memory changing data you shouldn't and will definitely screw up the program and probably crash. | |
Re: [QUOTE=nikita_knp;543376]hey actually i have to design a text editor in turbo C.. i havent made the code yet... plaese help me out.. or if anyone does have it plaese mail me at [email removed][/QUOTE] Help you with what? The design? Giving you code? How about starting with the design as … | |
Re: By not using [ICODE]scanf()[/ICODE] to input your data. [url=http://www.gidnetwork.com/b-59.html]See this series[/url] to see why, and how to fix it. | |
Re: Yes, you need a loop and a counter to count how many time your loop executes. Exit when counter == 5 OR guess == random_number Also be careful using = and == They are not the same and you have to use the right one for the right purpose. | |
Lately I've been seeing the following: Today I was looking at forums until about 2:45PM. This evening about 7:30PM I clicked on the [I]Go to first new post[/I] on various threads. I scroll up to previous posts and see many that have been added from 4PM on. Why are these … | |
Re: The way to do it in Turbo C is to use the functions [ICODE]kbhit()[/ICODE] and [ICODE]getch()[/ICODE]. You will not be using the [I]scan[/I] functions because they will stop the program. Anyway, you should [I]never[/I] use the [ICODE]scanf()[/ICODE] to read a string. [url=http://www.gidnetwork.com/b-62.html]Here's why[/url]. It would be useful to read the … | |
Re: See these links: #1) [url=http://www.gidnetwork.com/b-66.html]void main()[/url] #2) [url=http://www.gidnetwork.com/b-60.html]scanf("%c"...);[/url] #3) [url=http://www.daniweb.com/techtalkforums/announcement8-3.html]Code Tags[/url] #4) Works for me | |
Re: With todays compilers, you don't. Those headers are no longer used. | |
Re: [QUOTE=vijayan121;545050] got impatient ant tried it on a compiler. seems to work alright. [/QUOTE] Gee, maybe you should try that [I]first[/I] next time... :icon_rolleyes: | |
Re: [QUOTE=krnekhelesh;543922]I can help you. I have been using Turbo C++ and Borland C++ for the past 2 years. However please note that you cannot use Turbo C++ to output any sort of graphics as BGI graphics is not supported in windows.[/QUOTE] Not true. BGI works just fine at least through … | |
Re: I'd start with [b]plgriffith[/b]'s program and make a minor change [code] #include <stdio.h> int main() { char buf[] = "abcdeedcba\nabcdxxdcba\nabcxxxxcba\nabxxxxxxba\naxxxxxxxxa\n"; int i; i = 0; while (buf[i]) { putchar (buf[i++]); } return 0; } [/code] | |
Re: Problem #1: [QUOTE=Google Spider;543799]I'm not very good at structs and classes and haven't tried any problems, just read it from the book. [/QUOTE] Then you are not learning. All you're doing is reading which by itself is worthless. Start at the beginning of the book and do the work after … | |
Re: What [B]krnekhelesh[/B] said, except it's [I]ifstream[/I] since [I]use[/I] implies read, not write. To answer the rest of the question, searching your entire disk for the file is 1) difficult to program 2) time consuming to run Best to just read the file from a specific location. | |
Re: [QUOTE=jephthah;536483]nm[/QUOTE] What about New Mexico? | |
Re: [QUOTE=MidiMagic;532579]Get rid of this feature! There are times when ISPs go down. To blacklist someone because an ISP is down is RIDICULOUS! I can't change my email address without losing a lot of money.[/QUOTE] How can you lose money by changing your email address to DaniWeb? Just get a yahoo … | |
Re: Well, the first thing "TO DO" is to decide what you need "to do" for each section you labeled "TO DO". That is the first part of your assignment. Once you figure that out, we can help you implement the code (starting of course with your attempt). | |
Re: > I have my code written very nice on my compiler with proper spacing and good alignment, how do i put it on daniweb so it looks like my compiler. everytime i make a thread and space it right the preview of the post looks messed up.... 1) You could … | |
Re: A "database" does not have to be a pre-written data management system. It can be a file or three that contains the data you need for a project, and a few routines you write to access the data. Use the KISS principle ([B]K[/B]eep [B]I[/B]t [B]S[/B]imple [B]S[/B]tupid). | |
Re: [QUOTE=VernonDozier;535891]In C++, that would be something like this: [code=C++] if (m % n == 0) { // code to flag n as a factor of m } [/code][/QUOTE] Another option if you don't know the % operator is [code=C++] if ( ((m/n) * n) == m) { // n is … | |
Re: After 23 posts, did you ever notice there were words on the background of the textbox you enter all your posts? They also explain CODE tags. So do various threads at the top of the forums, and the Rules. | |
Re: [QUOTE=DangerDev;535067]u can also getch() but it doesnot work in some compiler.[/QUOTE] Why do people insist on making bad suggestions, especially after a good suggestion has been made? And if you read the Rules, they request [B]you[/B] use the word [B]you[/B], not the letter [I]u[/I], so people that don't speak English … | |
Re: Yes. Each letter has a numeric value. 'A' = 65, 'B' = 66, ... 'Z' = 90. So you can use a loop of some kind. | |
Re: Try an IF statement. If that doesn't help, you'll have to post your code so we can actually [I]see[/I] what you're trying to do. | |
Re: Another thread with the same question. Closing. | |
Re: Use [B].find()[/B] to find the spaces. If you find 2 spaces with 4 characters between them, use [B].replace() [/B]to replace the 4 characters. And remember, the end of the sentence may not end in a space, but it [I]may[/I] end in a 4-letter word. | |
Re: So what's the problem, other than not using CODE tags as requested in the Rules. Maybe you need to read [url=http://www.daniweb.com/techtalkforums/thread78223.html][b]Read Me:[/b] Read This Before Posting[/url] too. | |
Re: The string with the %x symbols in it are parsed to find each symbol. The letter is then looked at to figure out what field is supposed to go there. Then the string is changed by removing the %x and whatever field is requested replaces it. Usually the data comes … | |
Re: [QUOTE=nurulshidanoni;533835]How to arrange the number properly?[/QUOTE] One digit after another. If there is a portion that's below 1, add a '.' and that portion. If negative, '-' in front of all the digits. | |
Re: It would help if you'd [url=http://www.gidnetwork.com/b-38.html]format your code[/url] so we can follow it's flow. Proper indentation is crucial to understanding. | |
Re: Read [url=http://www.gidnetwork.com/b-38.html]this[/url] and [url=http://www.gidnetwork.com/b-66.html]this[/url], please. They will help you in the long run. | |
Re: [QUOTE=niek_e;533117]When you have all the input, just check if one of them is smaller then 0 and print a error message:[/QUOTE] Or better yet, wrap each input in a [ICODE]while[/ICODE] loop that tests for <0: [code=c] inp = -1; // force the value to be < 0 while (inp < … | |
Re: [QUOTE=nurulshidanoni;533900]How to correct the output, because for the bold it follows every studentid.[/QUOTE] Why do you insist on not giving us the information we need to understand what you want? When was the last time you read the post [url=http://www.daniweb.com/techtalkforums/thread78223.html][b]Read Me:[/b] Read This Before Posting[/url]? Start explaining in detail what … | |
Re: [QUOTE=jephthah;532813][QUOTE=ithelp;532808]I guess you meant stdio.h .[/QUOTE] oops, yeah. thanks and i also meant to put the last "printf" statement *AFTER* the close of the while() block. :P[/QUOTE] This is why we recommend you [I]test[/I] code you post. It generally doesn't help the poster if you give bad advice --- they … | |
Re: [QUOTE=nickthedivil;533724]I promise never ever ever to use gets() again[/QUOTE] Why? are you just going to believe him with no understanding of why he claims it's bad? :?: | |
Re: If you are converting [B]cm[/B] to [B]yd,ft,in[/B], first thing to do is convert your centimeters into inches. All this can be done with integers, you'll only be off by about 1/2 inch as long as you round properly.. Then, using the division you can get the number of yards. The … | |
Re: Only output the record if [I]client.GetAccountNumber() [/I] is the account number entered. Similar to your output [icode]while[/icode] loop. | |
Re: Please ignore all those bozos above. The reason your loop becomes infinite is the '.' is not valid for an integer, therefore 1) [ICODE]cin[/ICODE] reads the number up to the '.' and stops. The '.' is left in the input buffer 2) the next [ICODE]cin[/ICODE] tries to read the '.' … |
The End.