5,676 Posted Topics
Re: IMO, each member does not need to be welcomed. If they don't post in the introductions forum, it doesn't seem to be necessary. | |
Re: Please read this section of [url=http://www.daniweb.com/techtalkforums/faq.php?faq=daniweb_policies#faq_keep_it_organized]the Forum Rules[/url]. I suppose you should probably read all the sections, actually. ;) | |
Re: First, we need to know exactly what error you're getting and where the error occurs. Don't leave it to us to read and understand all 181 lines of code -- pinpoint the problem for us. And [B]rubberman[/B], [I]argv[/I] is not a vector but an array of char* -- but you … | |
Re: So did you try [CODE] cout <<"Without setprecision: "<<number<<endl; cout <<"With fixed and setprecision(3): " <<fixed <<setprecision(3) <<number <<endl; cout <<"The variable number again: " <<setprecision(0) <<number; [/CODE] That would be my logical test next. | |
Re: [QUOTE=Ancient Dragon;1529233]The next thing to do is NOT assume each line will contain exactly 1000 chracters. All you have to do is loop until '\n' is encountered. [icode] int i = 0; char buffer[255] = {0}; while( in.get(buffer[i]) && buffer[i] != '\n') { ++i; } [/icode][/QUOTE] Or better yet, make … | |
Re: In this case it's perfectly fine. You don't really have what's called a [I]loop counter[/I]. You have variables that are tested in the [B]while[/B] statement. A "[I]loop control variable[/I]" is used in a [B]for[/B] statement. That's where you should not change the value to exit the loop. | |
Re: [QUOTE=thekashyap;]Why not [ICODE]$pragma once[/ICODE] instead?[/QUOTE] Do all compilers support it? | |
Re: You compile both .cpp files into your project. The linker will take care of the rest. | |
Re: You can't define a function inside another function. Move it outside. | |
Re: First of all, when asking a question, as always, explain [B]exactly[/B] what the program does wrong. It's nice and extremely helpful to know the input and expected output as you posted, but "[I]it doesn't print in any semblance of that[/I]" is not descriptive enough. For all we know, the output … | |
Re: Use the function [iCODE]instr()[/iCODE] to find the COLON. Store that position in variable C1 Starting at [B]C1 [/B]test each character backwards (from [B]C1 [/B]to 1) looking for the SPACE. Store that location in [B]S1[/B] Starting at [B]C1 [/B]test each character forwards (from [B]C1 [/B]to end) looking for the SPACE. Store … | |
Re: That's because you sorted the array defined in your function ([B]a[/B]). When the function returns, that array is gone. What are you trying to accomplish? All this seems to be doing, assuming you get it to work, is sort the [B]ppg[/B] of all the players, assigning the lowest [B]ppg[/B] to … | |
Re: My question is why are you using dynamic memory to create a pointer then a single character? Unless this is a required part of an assignment, it's ludicrous. | |
Re: [QUOTE=figment56;]Hello All:[/quote] Hello you... [QUOTE=figment56;]I searched through the old posts, but could not find an answer as how to read numbers from a sequential text file & calculate the average of the numbers. [/quote] Then you would have seen you need to post code pointing out your immediate problem. And … | |
Re: After you read an integer (12) you still have the ENTER in the buffer (you [I]did[/I] press ENTER, didn't you?) After reading integers, you need to clear the input buffer before reading strings and characters. There is a sticky post that discusses this at the top of the forum. | |
Re: Version 1, 2, 3, 4, or 5? Have your tried [url=http://www.lmgtfy.com/?q=turbo+c+download]this[/url]? | |
When a post is moved, could you please change the post icon from the [i]purple new[/i] to the [i]grey nothing[/i] immediately? Leaving it a [i]purple new[/i] causes problems as we click on the 'new' icon, since that's what we see. | |
| |
Re: [QUOTE=Tinee;]I need suggestions on how to count the words, letters, characters on a file . I created a program of it however, when i use the "seekp(0L,ios::beg);", it doesn't go to the beginning. I want to just close and re-open the file but I think there is a better way … | |
Re: So why not post the most important part of the project -- the input file. If it's binary, we have one set of answers. If it's text we have another set. It helps to have all the info and a complete description. As it is, the description is spread over … | |
Re: [QUOTE=masih906;]Hi everyone , I'm learning C for couple of months and now I have a project in which I have to make the snake game in text enviroment !! So please someone tell me how can I do that and what I need to learn ??[/quote] You need to design … | |
Re: [QUOTE=skips;]I've tried to google the syntax for setw, but neither my book or the internet sources I looked at have led me to correct formatting. There is more to this program, but i'm just trying to get an idea for setw.[/QUOTE] [url=http://www.google.com/search?q=c%2B%2B+setw]This search[/url] gives the correct formatting for [ICODE]setw[/ICODE]. Don't … | |
Re: [QUOTE=Buffalo101;][code=C] 49: while (*name) printf("%c",*name++); [/code][/QUOTE] Not that good.... [code=C] while (*name) putchar(*name++); [/code] Much better.... Why use all the overhead of [ICODE]printf()[/ICODE] when [ICODE]putchar()[/ICODE] is perfectly designed for the task? | |
Re: [QUOTE=coding101;1526782]Anyone have an idea...[/QUOTE] Sure. Check the last bit, if 1, increment a count Shift the value 1 bit > Check again Continue until done. | |
Re: I don't see any attempt at trying to make a function. Give it a try, format your code, and repost with CODE tags so we can help you. | |
Re: [QUOTE=magravis;1526707]okay, well i figured it out that it just needed setw() it's basically, i have a txt file "HEY 10001011 10000111" and i need to take each of the 3 parts and input them. So far, i have the "hey" and the "first binary" stored into an array, how do … | |
Re: [url=http://www.google.com/search?q=plez]plez?[/url] [B]gerard[/B] did help. It also might help it you read the Member Rules as asked when you signed up. | |
| |
Re: Look carefully at the prototypes. Do they match the actual function? Do your calls match what the function is expecting? | |
Re: Since I can't read your code because of the lack of [url=http://www.gidnetwork.com/b-38.html]formatting[/url] I'll just give you a generic idea using [QUOTE]An integer array of 13 numbers: 3, 4, 5, 3, 2, 1, 3, 4, 5, 3, 2, 3, 5 An integer array of 5 counts intialized to all 0. [/QUOTE] … | |
Re: "The error" is certainly descriptive. Maybe "the problem" needs to be fixed. | |
Re: Why? Since I'm not a Facebookie not a Tweetie, I'm honestly curious as to why all this linking is a good thing. What does it really do for a member? for DaniWeb? | |
Re: Try [url=http://www.gidnetwork.com/b-38.html]formatting your code[/url] properly and I'm certain the error will jump out at you. | |
![]() | Re: [iCODE]someFunc(ptrToArray);[/iCODE] By the way, there is no [I]BYTE[/I] in C ![]() |
Re: So pass a char* instead of a char? Are you going to keep asking obvious questions until we write your whole program for you? | |
Re: Maybe you can point out about where you input is so we can find it? Asking us to look through 5 files and 300 lines of code is a little much, don't you think? | |
Re: Read each line Convert the first value to integer. Skip over characters until you find the ',' Convert the next value to integer. Skip over characters until you find the ',' continue until done. | |
Re: One [B]for()[/B] loop with one [B]printf()[/B] would be much easier. And if you [url=http://www.gidnetwork.com/b-38.html]format your code[/url] we all could follow it better. | |
Re: In programming, there is no "[I]right way[/I]" to do most things. There's this way, and that way, and the other way. The one you choose depends on what you know and what you are doing. In this case, after you open the file, you can use [iCODE]file >> label[/iCODE] to … | |
Re: Do you know the maximum number of values on a line? That would tell you how large to make the arrays of integers. By the way, in your [iCODE]fscanf()[/iCODE], what does the [B]%f[/B] do? | |
Re: Where's the [B]close [/B]that matches the [B]open [/B]on 193? | |
Re: I have heard that [B]Knuth[/B] actually designed an algorithm that [I]required[/I] a GOTO. It could not be removed using flow control. I don't know more than that, but I believe it was created in response to the "GOTO's are bad and unnecessary" movement -- just to be ornery. | |
Re: Probably because studentGPA[counter] is never 99 or greater until it's too late. | |
Re: Probably the most useful function available in C for this task is [url=http://www.google.com/search?q=isalnum][B]isalnum()[/B][/url]. It will aid you extremely well in ignoring non-variable-name characters -- although watch for '_'. | |
Re: [QUOTE=ChaseRLewis;]I know printf prints to "stdout" how exactly [/quote] By definition on the standard. Beyond that, don't know, don't care. Just need to know that it works.... [QUOTE=ChaseRLewis;]can I change the pointer to a class of mine that i'd prefer to handle the output string? [/quote] What pointer? | |
Re: Probably doesn't work. You're supposed to tell [B]us[/B] what's wrong. | |
Re: When you output the values, you've already incremented [B]loopcounter[/B] past the values you just loaded... You're outputting garbage. | |
Re: [QUOTE=Labdabeta;] I left out some of the code that I wish to keep to myself. But I have isolated the problem and it seems as though while loop is never excecuting. This happened before I changed from while{} to do{}while as well. Any ideas why this isn't working?[/QUOTE] It's working … |
The End.