1,088 Posted Topics

Member Avatar for zawpai

>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 …

Member Avatar for zawpai
0
157
Member Avatar for Valmian

int clothing(int *, int *, int *, char [COLOR="Red"]*[/COLOR][]); /* prototype */ Remove the * in red

Member Avatar for Duoas
0
386
Member Avatar for ravi_forum

[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 …

Member Avatar for Salem
0
921
Member Avatar for sara_84

[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 */ }; …

Member Avatar for iamthwee
0
172
Member Avatar for zeiken
Member Avatar for Aia
0
49
Member Avatar for chaosatom333

[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 …

Member Avatar for iamthwee
0
283
Member Avatar for rxylion

>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 }; …

Member Avatar for Aia
0
92
Member Avatar for controlsi

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 …

Member Avatar for Aia
0
90
Member Avatar for Barefootsanders

[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 …

Member Avatar for Aia
0
113
Member Avatar for sk8ndestroy14

[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.

Member Avatar for palegray.net
0
2K
Member Avatar for boyz

[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?

Member Avatar for WaltP
0
119
Member Avatar for boyz

[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.

Member Avatar for Duoas
-1
127
Member Avatar for mosullivan

[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

Member Avatar for danzona
0
80
Member Avatar for RexxX
Member Avatar for Aia
0
3K
Member Avatar for Gia

[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]

Member Avatar for bitRAKE
0
101
Member Avatar for Ratte
Member Avatar for Aia
0
99
Member Avatar for jimwalther

[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]

Member Avatar for chandrasekharn
0
105
Member Avatar for tehloki

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: …

Member Avatar for Salem
0
80
Member Avatar for imran_s

[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 …

Member Avatar for Aia
0
4K
Member Avatar for LilLady

[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 …

Member Avatar for Duoas
1
145
Member Avatar for deadswitch

[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]

Member Avatar for Aia
0
139
Member Avatar for ITapprentice

[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 …

Member Avatar for Narue
0
218
Member Avatar for locy

>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!

Member Avatar for Aia
0
77
Member Avatar for theteamdrunk

[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 …

Member Avatar for Aia
0
210
Member Avatar for tech2chill

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.

Member Avatar for tech2chill
2
479
Member Avatar for BensonRoss

[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().

Member Avatar for Aia
0
183
Member Avatar for redaqen

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 ) …

Member Avatar for Ancient Dragon
0
155
Member Avatar for Dave Sinkula

[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 …

Member Avatar for scru
3
778
Member Avatar for the.alchemist

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 ) …

Member Avatar for Salem
1
116
Member Avatar for appuguy

[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 …

Member Avatar for Aia
0
114
Member Avatar for crunchycrisp

[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 …

Member Avatar for Aia
1
154
Member Avatar for theteamdrunk

[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

Member Avatar for Duoas
0
122
Member Avatar for Badong Ang Lim

>(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?

Member Avatar for Badong Ang Lim
0
441
Member Avatar for arkane

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 ( …

Member Avatar for arkane
0
148
Member Avatar for mt171406

[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].

Member Avatar for Aia
0
90
Member Avatar for mt171406

[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 …

Member Avatar for mt171406
0
345
Member Avatar for rocksteady911

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

Member Avatar for Aia
0
120
Member Avatar for Ptolemy

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]” …

Member Avatar for Dave Sinkula
0
414
Member Avatar for megan-smith

[quote=megan-smith;455355] any ideas?[/quote] Yes, don't use scanf. Link [URL="http://www.daniweb.com/code/snippet266.html"]here[/URL].

Member Avatar for WaltP
0
585
Member Avatar for csteverun

>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].

Member Avatar for csteverun
0
107
Member Avatar for The Dude

[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 …

Member Avatar for Lardmeister
0
423
Member Avatar for bobei89

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> /* …

Member Avatar for bobei89
0
217
Member Avatar for woozyking

[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 ? …

Member Avatar for Ptolemy
0
338
Member Avatar for theteamdrunk

[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', …

Member Avatar for Aia
0
103
Member Avatar for Alexbeav

[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] …

Member Avatar for iamthwee
0
503
Member Avatar for rohit83.ken

[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.

Member Avatar for ithelp
0
71
Member Avatar for Justmehere

>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 …

Member Avatar for dwks
0
120
Member Avatar for Paulville

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 …

Member Avatar for Salem
0
160
Member Avatar for Sh13

>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.

Member Avatar for Aia
0
305
Member Avatar for #include_rose

[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 …

Member Avatar for #include_rose
1
754

The End.