1,088 Posted Topics
Re: [CODE]/* A program to count the number of grades occurring in the input */ #include <stdio.h> #define DEBUG int main() { /* Declare variables */ int a; int b; int c; int d; int f; int others; [COLOR="Red"]int ch; /* for input */[/COLOR] /* Initialize variables at zero */ a … | |
Re: [QUOTE=lionaneesh;1167772]Exercise 1-9. Write a program to copy its input to its output, replacing each string of one or more blanks by a single blank. help ME WID THIS .........[/QUOTE] What's wrong with `with'? It only takes one more character than `WID' to type, ... but then, you don't care about … | |
Re: [B]shetnok13>[/B] I can't subtract the cost from the input of the user..[.] Logic dictates that you must know how much it cost the choice of beverage. After that you need the amount payed, supposedly it would have been entered into variable `b' (you wrote:[ICODE]scanf("%d",&b);[/ICODE]) then you compare to see if … | |
Re: [QUOTE=churni;1166145]hi, iwhen i call it again its adding the value to the previously displayed number unless i close the whole program down and start again. how do i reset the value each time i call the function. [/QUOTE] [ICODE][COLOR="Red"]static[/COLOR] int i=0;[/ICODE] The static keyword makes the i to retain the … | |
Re: [QUOTE=sam_021;1166338]Hi basically i dont have time to do this coursework , due to overload of work .. it probably take like an hour for some1 who knows what they are doing .. ill pay like 15-20 quid ?[/QUOTE] most who post here dunno wut they're doin. and those that know … | |
Re: [QUOTE=abhishekvarmag;1165746] ..............................plzz modify this[/QUOTE] Done! I deleted it! | |
Re: [B]jephthah>[/B] And I would use both "strtok" to parse the strings between the separator characters I do not care about strtok() much. It doesn't work with read-only strings like the literal "this string", since it has to modify the given string to token it. | |
Re: jephthah> And I would use both "strtok" to parse the strings between the separator characters I do not care about strtok() much. It doesn't work with read-only strings like the literal "this string", since it has to modify the given string to token it. | |
Re: [CODE=c]/************bubble sort******************************************************/ void bubblesort ( int i){ int x,y,j; float temp; char buff[BUFSIZ]; float a[N]; FILE *in; in=fopen("rand.txt","r"); i=0; while(fgets(buff,BUFSIZ,in)!=NULL){ a[i]=atof(buff); i++; }[/CODE] Let me analyze the first fifteen lines. [ICODE]void bubblesort ( [COLOR="Red"]int i[/COLOR]){[/ICODE] That i parameter will become a copy of the argument, since you assign 0 to … | |
Re: [B]lugan>[/B] For the input i just want to use scanf(), and then it says that the Count function MUST use a getchar() to read one letter of the string at a time and go until ENTER or \n is pressed. There's a conflict as per the description. getchar() reads only … | |
Re: [CODE]int totalLen = strlen(formatstr) + strlen(name); [/CODE] I would try to avoid this kind of statements since the order of evaluation of the two functions is not defined. If one function affects the result of the other, then side effects will result. [CODE]char* buffer = (char*) malloc (sizeof(char) * totalLen); … | |
Re: Isn't the cube just the multiplication of itself by three times? | |
Re: [QUOTE=shah1248;1148640]Please use gets() instead of scanf() if you expect spaces in the user input. scanf() does not handle spaces the way you want it to work.[/QUOTE] gets() is not an option, because there's no way of controlling how much data can be inputed. There's no way of using it safely. … | |
Re: Added comments where things are not right. Did not pay attention to logic of program. Need work on how to place {} correctly as a block. Need to work on usage of switch. Need to work calling functions. Need to work in proper formatting. [code=C]/* # include <iostream> This is … | |
Re: Your code is not portable. You are using functions that do not work in Windows 7 | |
Re: [QUOTE=johndoe444;1149251]Frequently we need to copy-paste a code snippet and compile-run it. The problem is that the lines of code are tagged by line number. So what utility to use to elegantly discard the line numbers?[/QUOTE] Your question is ambiguous at best. I might have to make some assumptions If you … | |
Re: Consider this as a friendly warning. You will be ignore by those that can really help you if you don't use the proper C code tags when you post code. Example [URL="http://www.daniweb.com/forums/thread93280.html"]here[/URL]. | |
Re: [QUOTE=Salem;1155929]8 posts, no code tags. You've got two more attempts to get your act together.[/QUOTE] Take it as a warning, but as a honor as well that you did not get completely ignored, for purposely ignoring the code of conduct of this forum. | |
Re: A little [URL="http://www.tenouk.com/ModuleZ.html"]something[/URL] about memory | |
Re: [QUOTE=goodeye28;1155279]anyone can help me?[/QUOTE] You are asking for help. However, what you want is different from help. You want someone to write the program for you. This forum is not for that. | |
Re: [CODE]condition = fgets(save,30,reading);[/CODE] fgets() returns a pointer to a string. condition is an int declare condition as such: [ICODE]char *condition;[/ICODE] [B]save[/B] is a buffer of 100, but you only use 29 + the nul terminator '\0' A better statement would be: [CODE]fgets( save, sizeof save, reading ); [/CODE] [ICODE]printf("[COLOR="Red"]\n[/COLOR]%s",save); [/ICODE] … | |
Re: >Sounds easy enough. Let me get right on that. Sarcasm statement that sets the note of the rest of the blog article. >I think Mark Shuttleworth should pay for it--seriously. He has the money. It's his idea. Let him shell out the bucks for it. Very typical of leeches' philosophy. … | |
Re: [QUOTE=strmstn;1151666]But it isn't necessary. prog.cpp will compile anyway.[/QUOTE] Of course, that it most likely will compile. Nevertheless, that will create a C++ program and not a C program. [B]Sad[/B] that what it should be obvious, it needs to be explained in just great detail. | |
Re: Instead of using a printf() to display the random numbers, store them into an array of int. | |
Re: > (For some reason my browser doesn't recognize the fact that this isn't a text file.) My browser also thinks is a text file. | |
Re: .c files do not get called in the shell to be interpreted, they need to be compiled, and then linked as part of a program. | |
Re: [QUOTE=Aurorian;1147817] Still not working correctly. Again I'm terribly sorry for this double or quadroople posting, but I'm not allowed to edit any previous posts.[/QUOTE] It is perfectly fine to post any updated code again. Once a post is summited there's only a forty-minutes window of opportunity for editing. [QUOTE=Aurorian;1147817] Never … | |
Re: If I tell you that it will reflect, would it make you brave enough to try to compile a piece of code for yourself? | |
Re: [QUOTE=MyrtleTurtle;1148419]That code works fine for me (in Dev-C++). No errors, no warnings.[/QUOTE] [QUOTE=akssps011;1148517]Worked perfectly on Codeblocks. Which compiler are you using ?[/QUOTE] Interesting. [CODE]printf("%06[COLOR="Red"]f[/COLOR]\t %5.2f\t %5.1f\t %5.1f\t %8.2f \n\n\n", [COLOR="Red"]clock[j][/COLOR], wage[j], hours[j], woOt, gross); [/CODE] It doesn't flag clock[j] as trying to convert an int to a float? It doesn't … | |
Re: [QUOTE=gerard4143;1146775]Well I think this is the last version...I think or hope. I starting to get a love/hate relationship with shell scripting...its really something but I'm not really sure what...;) [/QUOTE] Are you giving up before achieving an one-liner? ;) A few points if I may. When making use of test, … | |
Re: You missed to read about the forum posting [URL="http://www.daniweb.com/forums/thread78060.html"]expectations[/URL] and proper [URL="http://www.daniweb.com/forums/thread93280.html"]code tagging[/URL]. I suggest you stick around and learn why your posted code is not a good example. | |
Re: [QUOTE=donelliewhyte;1145400]I am not really getting an error its just printing nothing[/QUOTE] This > [ICODE]while(number!=info.regis); [/ICODE]and this > [ICODE]if (info.regis!=number)[/ICODE] would work if they were int or float type, but it does not work as intended if they are array of chars. For that you can use strcmp() [ICODE]while ( strcmp(number, … | |
Re: ...Hmm, I see it, I want to say; almost feel that.. Is there any variable in your life that has not been yet initialized?, something starting as ...name, or number or n, something with... that starts with n?. Yeap! I feel I have to validate that. Thank you for calling, … | |
Re: [CODE][COLOR="Red"]input[/COLOR] = scanf("%f %d", &base, &exp);[/CODE] scanf() returns an int type, however input is of float type. Not that you use input for any reason. [CODE][COLOR="Red"]float pos_power[/COLOR](float base, int exponent)[/CODE] pos_power returns a float type, and [ICODE]result = pos_power(base, exp); [/ICODE] is expecting it, however you do not make any … | |
Re: [QUOTE=alma27534;1143091]The program compiles and this is the the output I get: ?Invalid number of arguments Press any key to continue . . . Can somebody please take a look at this program and give me some ideas? [/QUOTE] You must not be entering the right amount of parameters when running … | |
Re: Here, this is a [URL="http://www.daniweb.com/forums/thread78060.html"]pointer[/URL] | |
Re: [CODE]lines = realloc(lines, (size += 1) * sizeof(char*));[/CODE] On realloc failure a new pointer is made pointing to NULL and the original block is lost and not freed. | |
Re: [CODE=c]printf( "Enter sale amount $: " ); fflush( stdout ); /* because there's not newline at the end of printf string argument */ if ( scanf("%f", &fSale) ) /* scanf returns a positive int if successful, the if checks that */ { if ( fSale > 0.0 ) { printf( … | |
Re: Oh, no. I smell conspiracy plots. I can almost tested in the air. The Cubans, it was the Cubans. Castro send his assassins. ;) ...But Sir, the bullet says: Made in China. | |
Re: The problem is in how awk accepts an external variable, in this case $dat. [CODE]awk [COLOR="Red"]-v Var_date=$dat[/COLOR] '{if(( $5 > 200 ) && ( $6 == [COLOR="Red"]Var_date[/COLOR] )) [/CODE] | |
Re: [QUOTE=Dave Sinkula;1125081]I think this code would be a great little test sample for "find the bugs". [I'm thinking of recent threads on the topic of code and job interview.] Maybe not all bugs, but "issues", "don't do this" things, etc.[/QUOTE] You are too kind with "Maybe not all bugs." Without … | |
Re: Stubaan> I do not know how to solve 3) - how do I write the confounded value I have read from input2.txt into the exactly correct position within time.txt? Let's get this last part first out of the way. You don't change it in place, you save it to a … | |
Re: [CODE=bash]for songs in $(cat "~Desktop/1/list.txt"); do cp $songs NewSongs/; done [/CODE] The while loop is more appropriate for it. The for loop will need the $IFS (Internal Field Separator) modified. [CODE=bash]while read songs do cp "$songs" NewSongs/ done < ~Desktop/1/list.txt [/CODE] | |
Re: Welcome to the forum. Your post would be appropriated if it is pertaining to C programming. As it stands we don't know until people download the attachment, and many do have apprehensions about doing so. You forgot to ask a question concerning where you are having problems. I would like … | |
Re: PetuniaRose> The function of presidents, governors and mayors is only to execute the will of the folks who elected them. No man/woman has discovered/devised a system that would prevent the genuine will/voice of the people to be manipulated, corrupted for political agendas. On the other hand, it is most likely … | |
Re: [QUOTE=ramyasowbhagya;867911]try randomize function header file stdlib[/QUOTE] And why not use a [I]flux capacitor[/I]? Everyone knows that it will produce the [I]jiggawatts[/I] necessary to create a matrix. I get it now; it is the plutonium, isn't? @mindbender. Without showing a minimum of the effort you have putted into it, already, you … | |
Re: Dokino> Could you explain me this part [ICODE]print '%s is %.3fmm\n' % (x,mm)[/ICODE] print accepts a string with operants to be formatted. [B]'[COLOR="Red"]%s[/COLOR] is [COLOR="Red"]%.3[/COLOR]fmm\n'[/B] The first two % gets substituted by the variables x and mm respectively. %s tell print that it should be formatted as a string, %.3f … | |
| |
Re: [QUOTE=er.imran2006;1087000]Want to merge multiple text file items into a single text Please give code [/QUOTE] Please, read the forum rules. We do not give code. You show effort and we might help you (with suggestions) how to achieve your goal. | |
Re: johndoe444> from where did this garbage values come from? From [ICODE]int id[NUMTHREADS];[/ICODE] that is not initialized. |
The End.