1,088 Posted Topics
Re: >Example: Now you only have to port it to C. By the way. I am having troubles making it work in Dev C++. As a C++ compilation I get this error: `GetConsoleWindow' undeclared (first use this function) As a C I get the following error: undefined reference to `GetConsoleWindow' I … | |
Re: int clothing(int *, int *, int *, char [COLOR="Red"]*[/COLOR][]); /* prototype */ Remove the * in red | |
Re: [CODE]printf("%d",a++ - a++);[/CODE] Undefined Behavior. Meaning, is legal C syntax but is outside of any established agreed process defined in the C standards. Therefore, the compiler may or may not interpret or process the given statement in the correct intent. Which rule is a++ - a++ not following? Well, it … | |
Re: [QUOTE]typedef struct node node struct { int [/QUOTE] Is it obvious you are trying to define a structure type, but that's not the way of doing it. [B][I]exempli gratia[/I][/B] [CODE=C] typedef struct node { int first; int second; int etc; /* i.e. char, floats, arrays, pointer or struct */ }; … ![]() | |
Re: [URL="http://www.daniweb.com/forums/thread50370.html"]Look up[/URL] | |
Re: [QUOTE=chaosatom333;485639] [CODE=C]for(fill = 0; fill < (m-1); ++fill) { if(atomic_num[index_of_min] <= atomic_num[fill]) { temp = atomic_num[index_of_min]; atomic_num[index_of_min] = atomic_num[fill]; atomic_num[fill] = temp; } ++index_of_min; } for(j = 0; j < (m-1); j++) fprintf(outp,"%d\n", atomic_num[j]); [/CODE] [/QUOTE] It looks to me that you were trying to implement a bubble sort. For … ![]() | |
Re: >id like to ask if ever you could give me a very simple Array program. [CODE=C] /* * integers.c * display an array of integers in consecutive order * author: Aia */ #include <stdio.h> int main ( void ) { int integers[] = { 1, 2, 3, 4, 5 }; … | |
Re: Starting somewhere for no particular reason: [CODE]arr[][STR_SIZE]; //is this legal for me to use?[/CODE] It would be legal if you would have initialized arr, however since you didn't the compiler doesn't know how much space must set apart for arr. arr[][STR_SIZE] = { "One", "Two", "Three" }; /* This would … | |
Re: [QUOTE=Barefootsanders;482650]Oo got ya. Thanks[/QUOTE] Careful, checking for inequality using float is not an exact science due to the way a real number is stored in memory. Most like it [B]( y != 0.01 ) [/B]will return a [B]1.000000[/B] even when it should have return a [B]0.000000[/B] if you use a … | |
Re: [quote=jbennet;398601]Kick his ass! ;)[/quote] I hope not. I am ruling for Rashakil now. Third time is the charmed one. Sorry bother. C'mon Rashakil Fol don't let me down. | |
Re: [QUOTE=boyz;475926]can any one write a c program in which both the if and else statements should execute???[/QUOTE] Yes I can. Can you? | |
Re: [QUOTE=boyz;475910]without using swap function....[/QUOTE] I am going to say this as nice as I feel like. Stop bombing the C forum with trivial questions. You are just going to annoy everyone around here. Do some "work of your own first". Search the forum. Show some initiative. | |
Re: [QUOTE]if ((strcmp(p[j], p[i])) > 0)[/QUOTE] [B]p[j][/B] and [B]p[i][/B] are characters of a string. strcmp expects a string and not a char | |
Re: A [URL="http://www.gidforums.com/showpost.php?p=22742&postcount=2"]link[/URL] | |
Re: [QUOTE=Gia;467810] How should I implement the use of floats for my variables?[/QUOTE] [QUOTE=Duoas;467739]change all your [B]int[/B]s to [B]float[/B]s (and use the proper scanf and printf formats). [/QUOTE] [CODE=C] float PurchaseAmount; scanf( "%f", &PurchaseAmount ); printf( "This is the purchased amount: %.3f\n", PurchaseAmount );[/CODE] | |
Re: This[URL="http://www.daniweb.com/code/snippet443.html"] ONE[/URL] is better commented. | |
Re: [CODE]void ClearGameBoard(char board[]);[/CODE] That's it a prototype of the function. Inside the switch, the call should be: [CODE]ClearGameBoard( board );[COLOR="Green"] /* board is the name of any given string */[/COLOR][/CODE] | |
Re: Just something to think about it. [CODE=C] /* * bleh.c */ #include <stdio.h> int main ( void ) { int i; for ( i = 1; i <= 6; i++ ) { switch( i ) { case 1: puts( "One here, and two's coming right up" ); break; case 2: … | |
Re: [QUOTE=imran_s;466458]I did the same thing that you did on more than 1 computer and i get the same problem. Lets say u wanna convert 255 from base 10 to base 10. Youre supposed to get 255 as the answer, howeever i am getting 254. when i try to convert any … | |
Re: [QUOTE=LilLady;467517]ok i changed the the define PI part, but it is line 42 that is giving me trouble.The compiler that i am using is pelles c.[/QUOTE] Missing a parenthesis array[count] = amplitude * cos(2 * PI * (count * frequency / sample + phase) [COLOR="Red"])[/COLOR]; Line 33 [COLOR="Red"]n[/COLOR]++;[COLOR="Red"] /* undeclared … | |
Re: [code=C]void readRoom (rooms[]) { FILE *fin; int i = 0; fin = fopen("maps.c", "r"); if ( fin == NULL ) { /* some kind of error here */ } while ( fscanf(fin, "%s%d", rooms[i].room_name,&rooms[i].room_num) > 1 ) { printf("Room number: %d ... Room name: %s\n", rooms[i].room_num, rooms[i].room_name); } return; }[/code] | |
Re: [quote=Duoas;463515]What about [COLOR=green][B]'till[/B][/COLOR] (for [I]until[/I]) and [COLOR=green][B]nothin'[/B][/COLOR]? If those are also valid then your condition might easily be simply to check if the apostrophe is adjacent to a letter on [I]either[/I] the left [I]or[/I] the right. [/quote] I suppose the OP is trying to remove apostrophes from sentences as in … | |
Re: >here is my email(xxxxx@yahoo.com) i will be waiting to hear from you as i wish you all the best for your day. You just set yourself a date with SPAM. Good luck! | |
Re: [code]#include <string.h> /* no need for this include */ #include <stdlib.h> /* no need for this include */ void convert (char[COLOR=Red] filename[][/COLOR]); /* function is defined as [COLOR=Green]char *filename[/COLOR] not char filename[], even if it works like that */ printf("Enter the filename that you want to open. [COLOR=Red]/n[/COLOR]") /* you … | |
Re: Maybe it would be easier to think about it as an equilateral triangle in the middle filled with spaces. Here's an example of how to display an [URL="http://www.daniweb.com/forums/post458432-5.html"]equilateral triangle[/URL]. Then all you have to do is take care of the pattern of characters filling the surrounds. | |
Re: [quote=Duoas;463517]Or you could just use the [B]strspn()[/B] function: [inlinecode]if (strspn( dnaStr, "AaTtCcGg" ) < strlen( dnaStr )) puts( "error in DNA" );[/inlinecode][/quote] @[B]BensonRoss, [/B]make sure you include <string.h> for strspn() and strlen(). | |
Re: Line 39; 67: for([COLOR=Red]int y[/COLOR]=0; y<=MAX_ROWS; ++y){ Not proper [I][B]C89 syntax[/B][/I]. Declare int y outside the for loop. Line 41: fgets([COLOR=Red]str[/COLOR], sizeof [COLOR=Red]str[/COLOR], stdin); fgets( [COLOR=Green]str[y][/COLOR], sizeof [COLOR=Green]str[y][/COLOR] / sizeof ( char ), stdin ); Line 66: else if(strncmp([COLOR=Red]str[/COLOR], "list", 4)==0) if ( strncmp( [COLOR=Green]str[y][/COLOR], "list", 4) == 0 ) … | |
Re: [quote=Ancient Dragon;397217]yes, but at what cost? do you want your schoolbus driver spaced out on crack, or how about airline pilots ? Or government officials like the Queen and PM ? From what I've seen on TV the House of Lords (I think it is) already looks like a zoo … | |
Re: There's nothing wrong with your code except: [code]strcpy(tempSettings->setting[indexValue], newValue)}[COLOR=Red];[/COLOR] [/code] that semicolon needs to be before the closing } [QUOTE]I think it's something to do with the last line in changeSetting function, but I can't point where exactly! Am I supposed to add brackets somewhere ? ( i.e. (*tempSettings)->etc ) … | |
Re: [quote=the.alchemist;459699]For 1D arrays : use a single "for" loop to go through the array and print the current array element. This code for example will print all the elements of a 1D array. [code=C] int array[5]={9,8,7,6,5}; for(int i=0;i<5;printf("%d ",array[i]), i++); [/code] [/quote] I can only guess why you took all … | |
Re: [code] FILE *fin,*fout; fin = fopen(INFILE, "r"); [/code] When you try to open a file for reading you need to check afterwards if that file has been openned or does exist. [B]example:[/B] [code=C] FILE *fin; fin = fopen( INFILE, "r" ); if ( fin == NULL ) { printf( "Error … | |
Re: [quote=theteamdrunk;458982]what does the atof and atoi mean? I tried to run it with what you ahd written and it came up with undeclared, first use for atoi and atof.[/quote] atoi --> ascii to integer atof --> ascii to float | |
Re: >(about the posting I am still studying how it works, so for the meantime I just copy and paste my codes... sorry for that :p) What's so hard to understand? | |
Re: Since we are in the C forum. [code=C] /* * sizeof.c * Finding the size of some type */ #include <stdio.h> int main ( void ) { printf( "\nsizeof ( short ) occupy %d bytes", sizeof ( short ) ); printf( "\nsizeof ( float ) occupy %d bytes", sizeof ( … | |
Re: [quote=WaltP;457371]I'd start by attempting something. Just opening a file and not checking the error status does not even attempt to practice EOF-controlled loops. [/quote] He/she is in ignoring mode. That code was already corrected in the most basic errors, in this [URL="http://www.daniweb.com/forums/thread94186.html"]post[/URL]. | |
Re: [quote=mt171406;456881][inlinecode] I am having a problem trying to write a program that gets numbers from a selected file and returns each numbers sum of its perfect divisors. Could anyone give me a few pointers??[/inlinecode] [/quote] A few modificationes to your code and you're there. Read the extra comments. [code=C] #include … | |
Re: Found amusing that you did not feel the need to define the main function nor to declare the variables used in the for loop, but it was absolutely necesary to make a call to a no-portable function like getch(). Read [URL="http://www.daniweb.com/forums/thread93280.html"]here[/URL], for next time, how to post code | |
Re: Certainly I am grateful to Ptolemy and WaltP for continuing this conversation; if only because indirectly expose a fundamental principle of the heritage of the C language. Which is that “[B][I]C was developed by people that knew for people that know[/I][/B]” or in other words “[B][I]created by programmers for programmers[/I][/B]” … | |
Re: [quote=megan-smith;455355] any ideas?[/quote] Yes, don't use scanf. Link [URL="http://www.daniweb.com/code/snippet266.html"]here[/URL]. | |
Re: >Since this is really pathetic Been there, done that..., [URL="http://www.dwheeler.com/program-library/Program-Library-HOWTO/index.html"]found this [/URL]and [URL="http://www.adp-gmbh.ch/cpp/gcc/create_lib.html"]this[/URL]. | |
Re: [quote=sk8ndestroy14;363391]Yeah, I know. I was kind of mad with the ending of the second one but it kind of builds up to the third one.[/quote] Actually the movie was filmed to completion , but it was so big that the producers decided that it would server better their purpose if … | |
Re: Never define [B]main[/B] as [COLOR=Red]void [B]return[/B][/COLOR]. Start defining main as [COLOR=Green][B]int[/B] main( void )[/COLOR] or [COLOR=Green][B]i[/B][B]nt[/B] main ( int argc, char *argv[] )[/COLOR] if you are expecting arguments from the command line. >Sorry i never learn about <ctype.h>, isalpha, islower and isupper, is there other way??? [code=C] #include <stdio.h> /* … | |
![]() | Re: [quote=Ptolemy;455245] How about something more like this: [code=c] int my_strcmp ( const char *a, const char *b ) { while ( tolower ( (unsigned char)*a ) == tolower ( (unsigned char)*b ) ) { if ( *a == '\0' ) return 0; ++a; ++b; } return *a < *b ? … |
Re: [quote=theteamdrunk;455279]Basically, I am trying to copy the "message" to the "menu" and then display using the *(menu+i) and *menu notation.[/quote] [code=C] #include <stdio.h> #include <string.h> void restaurant(char*); void restaurante( char *menu, int size ); int main() { char message[17] = { 'W', 'h', 'a', 't', 's', ' ', 'f', 'o', … | |
Re: [quote=Alexbeav;454332]Hi all I'm studying C and I have to do an exercise that requires me to open a file and count the number of times a letter occurs,either small or capital. [/quote] There's a conversation about the same topic over [URL="http://www.daniweb.com/forums/thread90822.html"]here[/URL]. Maybe it might help. Take a look at [URL="http://www.daniweb.com/forums/thread93280.html"]this[/URL] … ![]() | |
Re: [quote=rohit83.ken;454622]removes comments from the given program and prints to the other file[/quote] Where's your question? What's the error? Did you not understand [URL="http://www.daniweb.com/forums/post454586-2.html"]Salem's[/URL] example/guidance? Ask a little more if you didn't; in the same post. No need to make another thread for the same problem. | |
Re: >Can anyone tell me what the purpose of C functions which start with "__" ? It's customary for compiler to name their functions and macros starting with some "_" or "__" in order to make it harder for an user define function to conflict in naming. It's recomended that you … | |
Re: In function `web_calc': /* in the function web_calc you have the following errors */ 92: parse error before `double' 96: `y' undeclared (first use in this function) /* y is a variable not declared before use */ 96: (Each undeclared identifier is reported only once 96: for each function it … | |
Re: >Is this the initializing process? No, that would allow you to print every element of a multi-dimensional array of 10 by 10. But you can use the same construct of two for loops to assign values to each element. | |
Re: [quote=#include_rose;453115]I didn't understand this though. How would I use fgets when I want to allocate memory dynamically? Here you are allocating static memory using line[BUFSIZ]; Am i right?[/quote] When you used [code] scanf("%d",&element->data);[/code] [B] element->data[/B] is the pointer of what is in [I]dynamic memory[/I]. When you use [I]fgets[/I] is the … |
The End.