218 Posted Topics

Member Avatar for SwiftDeath

GCC doesn't like your code. [code]sort.c: In function ‘read_list’: sort.c:13: warning: format ‘%s’ expects type ‘char *’, but argument 2 has type ‘int *’ sort.c: In function ‘insert_sort’: sort.c:75: warning: comparison between pointer and integer sort.c:78: warning: assignment makes integer from pointer without a cast sort.c:79: warning: assignment makes pointer …

Member Avatar for dwks
0
150
Member Avatar for n.aggel

So your question is, why does structure alignment apply to the last member of a structure? I think the answer is the same as for why structure alignment exists in the first place. Structure alignment makes the size of a structure a multiple of the machine's word size, which on …

Member Avatar for n.aggel
0
174
Member Avatar for RaDeuX

for loops generally have three sections. You've forgotten the [i]increment[/i] section. :) You're also missing a closing parentheses on the strlen() call . . . . But we know what you mean. :) [code]char inbuf[255]; // allocate array of 10 pointers and initialize them all to 0 char* pString[10] = …

Member Avatar for Ancient Dragon
0
1K
Member Avatar for flipjoebanana

[code]ex_1.emotion_options = (char **)malloc(sizeof(char *[MAX_EMOTION_SIZE]));[/code] That's uninitialized, so if you don't fill in MAX_EMOTION_SIZE elements of that array, then this will be freeing random values: [code] for(i=0; i < (ex_1.num); i++) free(ex_1.emotion_options[i]);[/code] The solution is to memset() the memory from the original call to zero, or easier yet, use calloc() …

Member Avatar for dwks
0
249
Member Avatar for java_girl

[code=c]while( line % 55 != 0 )[/code] Note that 0 % 55 is 0, so you'll pause before printing anything, and then display 55 lines ad infinitum. The best solution is probably to use something like this: [code=c]while( line != 0 && line % 55 != 0 )[/code]

Member Avatar for dwks
0
123
Member Avatar for nnhamane

You can read image files in your program in a standard way, if you want to write the reader yourself. wotsit.org is a good reference for this, as already mentioned. Or you can use a library to read image files into your program (which I would recommend). I can think …

Member Avatar for dwks
0
260
Member Avatar for 13L4D3

[url]http://board.theprogrammingsite.com/viewtopic.php?t=113&sid=57532b7c18db0b6089757cc195c714b4[/url]

Member Avatar for 13L4D3
0
184
Member Avatar for triadR

Sorry to go behind jephthah's back here, but if this is your original structure [code]typedef struct ip_header{ unsigned char headlen:4; // header len unsigned char ver:4; // version unsigned char tos; // type of service unsigned short length; // pack3t length unsigned short id; // ident unsigned short offset; // …

Member Avatar for jephthah
0
223
Member Avatar for raddix

It seems to me that .h files would be better for this, if all you're doing is managing constants (and not actual executable code). The standard place to include header files, of course, is at the beginning of a source file. Including it in the body of a function doesn't …

Member Avatar for dwks
0
157
Member Avatar for Q8iEnG

In order to use the ifstream fin variable that you declare inside the switch statement, you need to declare it outside the switch statement. For example: [code]ifstream fin; switch(choose) { case 1: fin.open("whatever.txt"); // ... } while(fin >> whatever) // ...[/code] [edit] Wow, I was beaten by over half an …

Member Avatar for Q8iEnG
0
208
Member Avatar for HLA91

Don't forget Dev-C++: [url]http://bloodshed/net/devcpp.html[/url] But I doubt that's the problem, if Ancient Dragon encountered the same issue.

Member Avatar for HLA91
0
105
Member Avatar for k.wiseman

It looks very nice. I guess I only have one comment at the moment, and that is that printing multiple lines of text is easier if you use triple quotes instead of lots of different print statements. For example: [code] print "You press one hand to your eyes and wave …

Member Avatar for k.wiseman
0
156
Member Avatar for michinobu_zoned

[code]puts("Give me input numbers, each separated by space."); //gcc error: puts was not declared within this scope[/code] You need to #include <stdio.h>, because that's where puts() is located. [quote]The question that I have now is, how do I specify exactly which process will have its core overwritten when I call …

Member Avatar for dwks
0
2K
Member Avatar for sivakrishna

So does Perl! In fact, you can do it with just one line, on the command line. [code]perl -pe 's/\s/g'[/code] But that's beside the point. Note that ssharish's code works, but it might be more efficient to shift the data inside the array. Or even just print characters that aren't …

Member Avatar for dwks
-2
168
Member Avatar for Anilbrp

You can use [b]start[/b] to control even more about the notepad window. For instance, [code]system("start /maximized notepad");[/code] will start notepad maximized.

Member Avatar for samarudge
0
2K
Member Avatar for Emperor456
Member Avatar for clavezza

What is [b]Packages/sqlite-3.2.7.entry[/b]? I dont think you should be passing it to the compiler.

Member Avatar for HOLYANDHOLY
0
242
Member Avatar for vinaygarg

Well, if [quote]The Reault should be a 32 bit value.[/quote] then you're out of luck, because, as you say, those numbers could not fit into a 32-bit integer. On the other hand, if you want one of your structures as the result . . . If the bases are the …

Member Avatar for vinaygarg
0
94
Member Avatar for bobei89

[code] if(letter[i]==str[count])[/code] Think about what you are doing here. You're saying something to the effect of, "if the [b]i[/b]-th element of letter[] equals the [b]count[/b]-th element of str[] ...". Since you've initialized letter[] to 'a', 'b', ... this works the first time. But then you go and increment letter[i]. So, …

Member Avatar for bobei89
0
217
Member Avatar for Alexbeav

gotoxy() is an ancient Borland function. It's very unportable. No new code should use it or anything from <conio.h>, such as getch() or clrscr(). [quote]if (b == "a" && b == "A") ++counta (this counts all "a"s and "A"s) [/quote] 'a' is a single character. "a" is a string. Use …

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

You're also [list] [*]using void main(), which is non-standard; [*]using while(!feof(fp)), which reads too far; [*]not checking if your program was passed enough parameters, so argv[1] and argv[2] might not contain file names; [*]not checking if the files could be opened, so your program will crash if this is the …

Member Avatar for ithelp
0
71
Member Avatar for Alexbeav

[quote]and if you overflow, reset to zero.[/quote] Not quite. That only works if you had gone one past the maximum allowed value. If you can add more than 1, you need to do this: [quote]If the result is beyond the limits of the alphabet (I assume like 35 for example),we …

Member Avatar for Dave Sinkula
0
145
Member Avatar for 51al

[code]switch ( Key ) { case 'R': case 'r': Key_r(); break; case 's': case 'S': Key_s(); break; case 27: exit(1); }[/code] Consider using tolower() or toupper() from <ctype.h>.

Member Avatar for Ancient Dragon
0
74
Member Avatar for phylon

You're looking in the wrong section of the manual. You don't want to create a vector view. Check out this section: [url]http://www.gnu.org/software/gsl/manual/html_node/Accessing-matrix-elements.html[/url] I think that this is what you seek: [quote][code]double gsl_matrix_get (const gsl_matrix * m, size_t i, size_t j)[/code] This function returns the (i,j)-th element of a matrix m. …

Member Avatar for dwks
0
140
Member Avatar for redaqen

[quote]When I inserted while(TRUE) it gave me an error saying that TRUE was undefined. Was that supposed to be while(true) ?[/quote] [b]TRUE[/b] is a commonly-defined constant -- windows.h defines it, along with a whole host of other libraries. [b]true[/b] is a C++ keyword, and a C99 keyword if you include …

Member Avatar for redaqen
0
137
Member Avatar for rocksteady911

Perhaps you should have a look at this. [url]http://en.wikipedia.org/wiki/Floating_point#Normalization[/url]

Member Avatar for dwks
0
99
Member Avatar for asilter

You can also set the arguments to your program without actually running the program, such as right at the beginning before you forget, with "set args [i]parameters[/i]". This is also the easiest way to start your program with no arguments after you ran it with some. [code](gdb) help run Start …

Member Avatar for dwks
0
100
Member Avatar for Justmehere

To elaborate: [quote]>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 …

Member Avatar for dwks
0
120
Member Avatar for locy

[quote] GCC defaults to C89. Add -std=c99 to the command line or to the settings of your IDE to use that syntax. Otherwise, you'll get a complain from the compiler.[/quote] Actually, GCC defaults to a [url=http://developer.apple.com/documentation/DeveloperTools/gcc-3.3/gcc/C-Extensions.html]GNU C[/url] mode by default, which is [url=http://developer.apple.com/documentation/DeveloperTools/gcc-3.3/gcc/Standards.ht]not the same thing[/url] as C89.

Member Avatar for Lardmeister
0
149
Member Avatar for rylix01
Member Avatar for rpjanaka
Member Avatar for dwks
0
65
Member Avatar for pdwivedi

[quote]Back to the software, if there is a makefile (and you have GCC installed), then at the command prompt, do these things - cd to the top-level directory of the software package - type 'make' and press return. This should set the whole build going.[/quote] If typing [b]make[/b] doesn't work, …

Member Avatar for dwks
0
106
Member Avatar for locy

[QUOTE=Aia;450310][B]FWIW[/B]: Some [URL="http://www.geocities.com/learnprogramming123/Cdownload.htm"]compilers[/URL].[/QUOTE] It recommends Miracle C! . . . Miracle C is a very broken compiler, a very bad thing to recommend to new programmers.

Member Avatar for dwks
0
148
Member Avatar for TkTkorrovi

Qt is released under two licenses. [url]http://trolltech.com/company/model[/url] It's released under the GNU GPL (not the LGPL), which means that it's under the copyleft and your program which uses Qt must also be released under the GPL. If you want to develop commercial applications with Qt, you have to obtain a …

Member Avatar for TkTkorrovi
0
3K
Member Avatar for rowly

The OP's code is also missing a closing curly bracket ([b]}[/b]) at the end of the for loop. This code is equivalent, but simpler: [code]for (i = 0; i < 52; i++) { deck[i] = i % 13; /* i modulo 13 */ deck[i] = i * 2; deck[i] = …

Member Avatar for WaltP
0
124
Member Avatar for AquilesBailo

Don't forget to include <ios> for std::streamsize. [edit] [url]http://cboard.cprogramming.com/showpost.php?p=635802&postcount=10[/url] whch leads to [url]http://cboard.cprogramming.com/showpost.php?p=614384&postcount=13[/url] [/edit]

Member Avatar for Ancient Dragon
0
171
Member Avatar for asilter

[code]process_values( values, sizeof values / sizeof[color=red]( int )[/color] );[/code] Consider [code]process_values( values, sizeof values / sizeof [color=blue]*values[/color] );[/code] If you're going to the trouble to use sizeof() to determine how many elements are in an array, why not use sizeof(*array) to get the size of each element in the array …

Member Avatar for Hamrick
0
127
Member Avatar for Fusina

You'll have to elaborate. Post the whole sentence. Well, it looks like you need to know about: [list] [*]File I/O. [url]http://www.cprogramming.com/tutorial/cfileio.html[/url] [*]Dynamic memory allocation. [*]String manipulation: comparison and replacement. [/list] How much experience do you have with each of those?

Member Avatar for dwks
0
137
Member Avatar for CRD

[code]while(indicator [color=red]=[/color] 'y')[/code] You want [color=blue]==[/color] for comparison.

Member Avatar for ~s.o.s~
0
69
Member Avatar for rugae

I don't think you can add enum values. By definition, enum values are constant: [quote]So when should you use enums? Any time you need a fixed set of constants.[/quote] From [url]http://java.sun.com/j2se/1.5.0/docs/guide/language/enums.html[/url] Have a look at that page, it could help.

Member Avatar for dwks
0
127
Member Avatar for adr1

Also see these programs for examples: [url]http://queatrix.awardspace.com/program.php?11[/url] [url]http://queatrix.awardspace.com/program.php?12[/url]

Member Avatar for jbennet
0
125
Member Avatar for srinath.sec

Not that it matters too much. I think that .lib files are the same format as .a files these days.

Member Avatar for dwks
0
96
Member Avatar for RobertNashon

The lines that are causing the code colourer to mess up are these: [code]cout<<"<A href="http://www.tuungane.org"<<endl">www.tuungane.org"<<endl; cout<<"<A href="mailto:tuunagane@yahoo.com"<<endl">tuunagane@yahoo.com"<<endl;[/code] To embed a '"' (double quote) character in a string, you need to escape it: [inlinecode]\"[/inlinecode] Also, strings cannot contain newlines. To insert a newline, use [b]\n[/b]. If you put a newline in …

Member Avatar for dwks
0
195
Member Avatar for MiloTN

This is, shall we say, an exceedingly bad idea: [code]char filename[] = "" ; // ... // Input filename. printf("\nEnter a filename : "); gets(filename);[/code] First you declare a string that can hold one character; then you use gets() to read it in. I suggest [code]char filename[BUFSIZ], *p; fgets(filename, sizeof …

Member Avatar for dwks
0
132
Member Avatar for livingsword

There are many functions that you are using that have no equivalent -- in fact nearly all; if there were exact equivalents then the programmer would have used those instead, most likely. This snippet supplies Linux code for gotoxy() and clrscr(): [url]http://www.daniweb.com/code/snippet64.html[/url]

Member Avatar for dwks
0
141
Member Avatar for zesmail

Maybe this will give you a rough idea: [url]http://www.digitalgrapevine.info/viewtopic.php?t=1618&sid=41bffcd94783310cb5d5e045381d96fc[/url]

Member Avatar for iamthwee
0
103
Member Avatar for developer4321

[url]http://www.sparknotes.com/cs/searching/hashtables/section1.html[/url] [url]http://www.cprogramming.com/tutorial/templates.html[/url]

Member Avatar for developer4321
0
122
Member Avatar for GreenDay2001

Here's another gotoxy() link: [url]http://faq.cprogramming.com/cgi-bin/smartfaq.cgi?answer=1044844545&id=1043284392[/url] Here's another useful Windows Console programming link, perhaps you'll find what you're looking for there: [url]http://www.adrianxw.dk/SoftwareSite/index.html[/url]

Member Avatar for GreenDay2001
0
486
Member Avatar for elcrapo

Really? . . . [url]http://eternallyconfuzzled.com/arts/jsw_art_rand.aspx[/url] Either way works, and some would recommend the OP's way over yours (myself included). If you want it to generate numbers outside of 1-19 or something, change these variables. [code] int lowest=1, highest=19;[/code] What exactly do you want?

Member Avatar for WaltP
0
141
Member Avatar for Xzantose

"Without a toolkit"? Sure, but you'd be writing a lot of platform-specific code. You could use regular old Windows programming. You could use the Gnome or KDE libraries. What operating system are you using? Why don't you want to use a toolkit?

Member Avatar for blacklight
0
145

The End.