218 Posted Topics
Re: 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 … | |
Re: 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 … | |
Re: 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] = … | |
Re: [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() … | |
Re: [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] | |
Re: 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 … | |
Re: [url]http://board.theprogrammingsite.com/viewtopic.php?t=113&sid=57532b7c18db0b6089757cc195c714b4[/url] | |
Re: 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; // … | |
Re: 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 … | |
Re: 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 … | |
Re: 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. | |
Re: 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 … | |
Re: [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 … | |
Re: 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 … | |
Re: 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. | |
Re: What is [b]Packages/sqlite-3.2.7.entry[/b]? I dont think you should be passing it to the compiler. | |
Re: 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 … | |
Re: [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, … | |
Re: 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 … ![]() | |
Re: 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 … | |
Re: [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 … | |
Re: [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>. | |
Re: 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. … | |
Re: [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 … | |
Re: Perhaps you should have a look at this. [url]http://en.wikipedia.org/wiki/Floating_point#Normalization[/url] | |
Re: 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 … | |
Re: 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 … | |
Re: [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. | |
| |
Re: Also remove "-s" (strip) if it exists. I'm pretty sure it takes precedence over -g. | |
Re: [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, … | |
Re: [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. | |
Re: 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 … | |
Re: 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] = … | |
Re: 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] | |
Re: [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 … | |
Re: 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? | |
Re: [code]while(indicator [color=red]=[/color] 'y')[/code] You want [color=blue]==[/color] for comparison. | |
Re: 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. | |
Re: Also see these programs for examples: [url]http://queatrix.awardspace.com/program.php?11[/url] [url]http://queatrix.awardspace.com/program.php?12[/url] | |
Re: Not that it matters too much. I think that .lib files are the same format as .a files these days. | |
Re: 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 … | |
Re: 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 … | |
Re: 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] | |
Re: Maybe this will give you a rough idea: [url]http://www.digitalgrapevine.info/viewtopic.php?t=1618&sid=41bffcd94783310cb5d5e045381d96fc[/url] ![]() | |
Re: [url]http://www.sparknotes.com/cs/searching/hashtables/section1.html[/url] [url]http://www.cprogramming.com/tutorial/templates.html[/url] | |
![]() | Re: 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] ![]() |
Re: 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? | |
Re: "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? |
The End.