218 Posted Topics
Re: You have a lot of repetitive code there that could go outside of the if statement . . . | |
Re: [QUOTE=Mac.Z;312016]Hello, I'm getting started with C++ and have some questions about the variable types: 1)The size of a variable type, is it defined by the compiler or computer or both? and why it differ from one to another?[/quote] C was designed with efficiency in mind. (And C++ was developed with … | |
Re: [quote] Pressing the INSERT key causes the editor to toggle between insert mode and overlay mode. In insert mode, when you type, characters to the right of the cursor are moved to the right to make room. In overlay mode, when you type, characters to the right of the cursor … | |
Re: You're also missing a closing curly brace [inlinecode]}[/inlinecode] at the end of your program, but that's probably just a typo. | |
Re: [quote]Q. Why is Turbo C not able to find any of my #include files? A. The compiler searches for include files in the Turbo C Include Directories. This option is specified under the Options/Directories menu. The INSTALL program initially sets this option to the directory where it copied all the … | |
Re: You might actually be getting a warning where you call system(), because system()'s prototype is in <stdlib.h>, which you haven't included. [code]char izbor[2];[/code] You can't expect that string to be able to store "da\0", which is three characters. Remember, you have to leave space for the NULL. Even if you … | |
Re: [url]http://www.daniweb.com/code/snippet83.html[/url] [url]http://www.daniweb.com/code/snippet72.html[/url] | |
Re: [QUOTE=joeprogrammer;296523]Yup, use the [URL="http://http://www.cplusplus.com/reference/clibrary/cstdlib/system.html"]system()[/URL] command. For example: [code] system("DIR C:\"); [/code] lists the contents of the C:\ drive. Simply enter in the path of the script, and you're good to go. Hope this helps [edit]Too slow...[/edit][/QUOTE] Presumably you meant [code]system("DIR C:\[color=blue]\[/color]"); [/code] Also see [url]http://faq.cprogramming.com/cgi-bin/smartfaq.cgi?answer=1044654269&id=1043284392[/url] | |
Re: That program is meant to be compiled with [url=www.delorie.com/djgpp]DJGPP[/url]. Use the version meant to compile with Borland compilers: [url]http://www.brackeen.com/home/vga/source/bc31/bitmap.c.html[/url] Better yet, stop using such an old compiler and get Dev-C++ and install the SDL (which has built-in support for .BMP files, and with SDL_Image supports .pngs, .jpegs, .tiffs, and many … | |
Re: [code]Error 1 error C4430: missing type specifier - int assumed. Note: C++ does not support default-int [/code] Use [b]int function()[/b] or [b]void function()[/b], not just [b]function()[/b]. Which line is this on? [code]Warning 3 warning C4154: deletion of an array expression; conversion to pointer supplied [/code] [edit] I get more errors … | |
Re: [quote]I am using code blocks with the gcc compiler and the gdb debugger (which is a little buggy itself). [/quote] How so? You just have to know how to use it. Here is one GDB tutorial: [url]http://www.dreamincode.net/forums/showtopic13243.htm[/url] Here is another: [url]http://www.cprogramming.com/gdbtutorial.html[/url] | |
Re: Try Wikipedia: [url]http://en.wikipedia.org/wiki/Device_driver[/url] | |
Re: [QUOTE=johnpeter1989;277903]for dates, there is an inbuilt structure in dos.h to get help in the cpp just get help on date the date structure has just 3 items,day month and year. there are in built functions to get current date the following code will fill the structure item d1 with the … | |
Re: [QUOTE=Akks_3;252374]hi! The point is, it will involve a huge overhead to switch to TC (as I have'nt installed it on my notebook). I just needed to plot a histogram on a graph in bcc. will WinGDI help. If so, kindly send me a rough code.[/QUOTE] I imagine the overhead would … | |
Re: basetsd.h isn't a standard header file, as you can find out by googling it. Therefore dropping the .h wouldn't help much; only the standard C++ header files have no extension. Of course, you're free to call the header basetsd without a .h; but there's no reason to believe that the … | |
Re: [code]#include < IOSTREAM >[/code] Header files are case-sensitive, and those spaces are part of the name, too. Use this instead: [code]#include <iostream>[/code] Then change [code]cout<<**weekdays;[/code] to [code][b]std::[/b]cout<<**weekdays;[/code] Then it will compile. The program's output will be [inlinecode]S[/inlinecode]; **weekdays is the same as weekdays[0][0]. The first character of the first string … | |
Re: [quote][quote]fflush dosn't work for input streams and I think it's system("cls"); instead of system("clear"); [/quote] system("cls") for windows system("clear") for unix(knoppix) the problem right now that i want to cocentrate at is Search function and Delete function. Anybody know. Pls help me. Urgent....... [/quote] As andor mentioned: Why not to … | |
Re: You know that your company's logo isn't a polygon. :) | |
Re: From [url]http://www.wcscnet.com/Products/CdrvPP/CdrvPPSupportQuestions%5B0001%5D.htm[/url] [quote]Make sure that you included the files CDRVPP.LIB, CDRVDL32.LIB, CDRVHF32.LIB, & CDRVXF32.LIB. They are found in the Lib directory for the Microsoft Visual C/C++ compilers and in the LibB directory for the Borland C/C++ compilers. [/quote] | |
Re: Your acceptInput() code doesn't have access to arraySize. :) | |
Re: I think that qualifies as spagheti code . . . . [code]fflush(stdin);[/code] Don't do that: [url]http://faq.cprogramming.com/cgi-bin/smartfaq.cgi?answer=1052863818&id=1043284351[/url] Do this: [url]http://faq.cprogramming.com/cgi-bin/smartfaq.cgi?answer=1044873249&id=1043284392[/url] | |
Re: [quote]It simply means that the storage space (number of bytes) in a double is twice the storage space of a float.[/quote] Actually, the ANI standard just states that a double must be at least as large as a float (and a long double at least as large as a double). … | |
Re: [code](source[pos] >= '0' && source[pos] <= '9')[/code] Look into [inlinecode]isdigit()[/inlinecode] in <ctype.h>. And isalpha() or isupper()+islower() for the other lines nearby. Have you every used getenv() before? . . . if not, try reading a man page or searching google for it. | |
Re: Here's one of your problems: [code]double area; /* [...] */ printf("Area = %.2lf\n", area); [/code] Only scanf() uses [b]%lf[/b] for doubles and [b]%f[/b] for floats. printf() uses [b]%f[/b] for both; it doesn't have a [b]%lf[/b]. [code] DATA input; while (input.shape != 4) { [/code] auto structures are not initialized, just … | |
Re: If all you want to do is pause the console before the program exits: [url]http://faq.cprogramming.com/cgi-bin/smartfaq.cgi?answer=1043803465&id=1043284385[/url] | |
Re: You can use the standard C function qsort(), which, despite its name, doesn't have to use a quicksort algorithm, just a sorting algorithm. If you want to just sort a couple of numbers then you could use the bubble sort (slow but simple). (Google for [url=http://www.google.ca/search?hl=en&q=bubble+sort&meta=]"bubble sort"[/url].) | |
Re: The keywords in C++ are listed here, and, as you can see, [b]flag[/b] isn't one of them: [url]http://www.cppreference.com/keywords/index.html[/url] | |
Re: [QUOTE=cyan033]If i type 3 as input i get "11=2Þ" if i remove the [inlinecode]strrev()[/inlinecode] function i get "Þ2=11" :P[/QUOTE] You could print the string backwards with a for loop: [code]for(int x = strlen(s)-1; x >= 0; x --) { cout << s[x]; }[/code] | |
Re: Put the [inlinecode]n2 = atoi(argv[2]);[/inlinecode] [i]after[/i] you check to see if the program got enough arguments (the [inlinecode]if(argc != 3)[/inlinecode]). Oh yeah . . . and add a semicolon. :) | |
Re: Use code tags, as the quick reply box suggests. Have you tried using templates? (The syntax can be hard to remember.) Why don't you search for some template tutorials or read a C++ book? | |
Re: That only generates 99 numbers. You should have "i<100". | |
Re: There are three types of loops in C and C++: for loops, while loops and do-while loops. You'll need to clarify a bit. It appears you're having trouble with a do-while loop? And how is piping involved? | |
Re: [quote]Instead you use strcmp from <string.h>.[/quote] Or rather, as you pointed out, <cstring>. :) | |
Re: [quote]Where do I install the header file?[/quote] If you don't know this then you probably shouldn't try to use "graphics code". You can put it where all your other header files are stored (bad idea), put it in the same directory as your code and use #include [b]"[/b]file.h[b]"[/b] (okay idea), … | |
Re: It's [url=http://www.google.ca/search?hl=en&q=gotoxy&btnG=Search&meta=]gotoxy[/url] for Borland C++, I believe. And you should use fgets() instead of gets(). You'll also definitely need to use getch() and kbhit(). Google for them for more info. | |
Re: [quote]there's an ignore function ignore (.... , .... ); this function 2 ignore some data from the input stream.[/quote] It looks like they mean the standard cin.ignore function. Why do you need to ignore three chars? Do you want to flush the input buffer? | |
Re: No, sorting the array would re-order the elements in the array. | |
Re: [code]return current_y,current_x;[/code] You can only return one value from a function. Use [reference] parameters. | |
Re: You should [b]delete[/b] anything you dynamically allocate with [b]new[/b]. | |
Re: If you call your functions many times, it might be more efficient to open the file once. | |
Re: main() returns 0 when no errors have occured. Your implementation of the bubble sort won't work. Try this: [code]void sort_array(int *array, int len) { int did; do { did = 0; for(int x = 0; x < len; x ++) { for(int y = x+1; y < len; y ++) … | |
Re: Link with -lstdc++ (or -lstdcxx under DOS), or use g++ (or gpp under DOS): [code]$ g++ template.cpp -o template $ gcc template.cpp -o template -lstdc++ C>gpp template.cpp -o template.exe C>gcc template.cpp -o template.exe -lstdcxx[/code] | |
Re: [code]Darray& Darray::operator= (const Darray& darray); //assignment operator[/code] -> [code]Darray& operator= (const Darray& darray); //assignment operator[/code] | |
Re: You should post your errors. It makes it much easier to figure out what's going on. Your .cpp file needs to #include your .h file. If you have a global variable in one file, to make it visible in another file, you have to declare it as extern. [code]int variable; … | |
Re: Something like this? [code]void fill_array(char **array, int xs, int ys, char set) { for(int x = 0; x < xs; x ++) { for(int y = 0; y < ys; y ++) { array[xs][ys] = set; } } }[/code] | |
Re: When you have more than one program in one directory, you usually don't want to always use the executable name a.out. You can pass the -o option to g++ to specify the output file: [code]$ cat > randword.cpp #include <iostream> #include <cstdlib> #include <ctime> using std::cout; int main(void) { srand(time(0)); … | |
Re: So this doesn't run: [code]CString bad; bad[999] = 'a';[/code] but this does: [code]char good[10000]; good[999] = 'a';[/code] It looks like a CString is equivalent to a char*. In that case, you need to allocate memory dynamically for it or use a char array. Your best bet would be to use … | |
Re: [code] [color=blue]int [color=red]f[/color] = atoi (command.c_str());[/color] if (command == "f") { fin >> arg1; [color=blue]result = [color=red]f (arg1)[/color];//THIS LINE IS THE ERROR[/color] cout << "factorial of " << arg1 << "= " << result << "\n"; fout << "factorial of " << arg1 << "= " << result << "\n"; … |
The End.