15,300 Posted Topics
Re: fflush(stdin) is non-standard and not supported by many compilers. fflush is used to force the operating system to write everything to the output stream. Since stdin is an input stream and not an output stream fflush(stdin) may or may not work, depending on what comiler you use. | |
Re: what compiler are you using? what operating system? what are the error messages? | |
Re: Here is one way to prevent duplicates BTW: assert() does nothing when the program is compiled for release mode instead of debug mode. [code] void uniquebag::insert(const value_type& entry) { assert(size () < CAPACITY); // check if the number already exists in the array bool found = false; for (size_type i=0; … | |
Re: There is no such thing as "Non Ansi C Standard". If its not in the Ansi C Standard then it must be, by definition, non-ansi C. | |
Re: The same way you would do it in a normal c++ program. [code] #include <vector> int main() { std::vector<int> array; } [/code] MFC has a lot of container classes, and depending on what you want to do, they may or may not be better than std::vector or std::list. Your compiler … | |
Re: So, you want to send something to a printer? What operating system? Is the printer connected directly to your computer or is it located on a network? Lazer printer or line printer? | |
Re: use fgets() to read a line, then for each line you can use strtok() to tokenize it, then atol() to convert from char* to int. Another way is to use strtol() in a loop. Example [code] int main() { char line[] = "12 23 34 45"; char* ptr; int n1[4]; … | |
Re: You have to call [URL="http://msdn.microsoft.com/en-us/library/aa363858(VS.85).aspx"]CreateFile()[/URL] to open the comm port. Then you use the win32 api [URL="http://msdn.microsoft.com/en-us/library/aa363194(VS.85).aspx"]Communications Functions[/URL] | |
It sometimes includes threads that I have recently answered. For example, click Unanswered Threads, post in one of them, then click Unanswered Threads again -- the thread you posted in still shows up, but this time it shows correctly that there was 1 reply. I would have expected it to … | |
Re: [URL="http://technet.microsoft.com/en-us/library/bb491009.aspx"]taskkill[/URL] | |
Re: Are you talking about precompiled header files? Both Microsoft's VC++ 2010 (and earlier versions too) and g++ support that (other compilers might too, I don't know). You have to create a header file that includes other header files as well as function prototypes, constants, classes, structures and externs. Then you … | |
Re: Freeky -- again, that code requires the use to hit the Enter key Nishinoran: since your program is already using kbhit() when the program returns to the place to begin getting keys from the keyboard you can flush all the keys with another loop using kbhit [code] while( kbhit() ) … | |
Re: OMG I hope he is not taking a college course ;) A better way to write that. Note that you don't need all those C header files. [code] #include <string> int main() { for(int i = 0; i < 1000; i++) { std::cout << i << '\n'; } std::cin.get(); return … | |
Re: Yes of course its possible. All you have to do is rewrite the entire file [code] open input file for read open temp output file for writing for read line read from input file remove what you want from the line write the rest to the output file close both … | |
Re: you can not use strcat() on the pointer returned by [URL="http://www.warpspeed.com.au/cgi-bin/inf2html.cmd?..%5Chtml%5Cbook%5CToolkt40%5CXPG4REF.INF+148"]getcwd[/URL]() because _getcwd() allocates a buffer only large enough to hold the path. You need to allocate a second buffer that is large enough to hold the string returned by _getcwd() and the string you need to add. The second … | |
Re: He could post the same thing in [URL="http://www.daniweb.com/forums/forum95.html"]Job Offers[/URL] without getting flamed or getting his phone number snipped. | |
Re: It might be safer to use a union, such as [URL="http://msdn.microsoft.com/en-us/library/ms221627(v=VS.80).aspx"]VARIANT[/URL].Your structure does not have to be that complicated [code] typedef struct { int type; union { char cVal; int iVal; float fVal; } val; }AnyVal; int main() { AnyVal val; val.type = TYPE_FLOAT val.val.fVal = 0.0F; } [/code] | |
Re: This is c++ forum, not C. Here is one way to do it, but I doubt that is that you really want. [code] int main() { cout << 3 << '\n'; cout << 323 << '\n'; cout << 32123 << '\n'; cout << 323 << '\n'; cout << 3 << … | |
Re: [URL="http://msdn.microsoft.com/en-us/library/12h9x0ch(v=VS.80).aspx"]CComboBox[/URL] does not have an items property. [icode](CComboBox*)(GetDlgItem(IDC_COMBO1))->AddString("Text");[/icode] | |
Re: you have to check for error, and if it occurs clear the input buffer See [URL="http://www.daniweb.com/forums/thread90228.html"]this thread[/URL] about how to clear the input buffer. [code] #include <iostream> #include <limits> using std::cin; using std::cout; int main() { int c; while(true) { cout << "Enter a number\n"; cin >> c; if( cin.fail() … | |
Re: [URL="http://delphi.about.com/od/adptips2006/qt/vkey2char.htm"]Here [/URL]is an example, I think its in vb but you should be able to translate it easily to C. | |
Re: include windows.h win32 api function [URL="http://msdn.microsoft.com/en-us/library/ms682453(VS.85).aspx"]CreateThread()[/URL] More about that [URL="http://www.codeproject.com/KB/threads/Threads_1.aspx"]here[/URL] | |
Re: Line 3: that is not the way to pass an array. Omit the []. All you do is pass the name of the array, like this: [icode]mergesortinplace(0, (length/2), array);[/icode] | |
Re: The program will not stop if there are still keystroks in the keyboard buffer, such as if you previously called scanf() to get an integer the '\n' will still be in the keyboard buffer. But you will have to post your program for anyone to give you more help with … | |
Re: You don't link the dll -- only the *.lib. One way to do it is by using pragma [icode]#pragma comment(lib,"mydll.lib") [/icode] Replace mydll.lib with whatever you named it. You will have to put the dll in either the program's current working directory or one of the folders specified in the … | |
Re: Variable x is not being changed inside that loop, so it will print the same value of x to the file 20 times. | |
Re: Are you telling us that you are an illegal immegrant to one of those countries? If you are -- then Shame on you. | |
Re: What does the program not do that you want it to do? What are the errors? We are not here to debug and fix errors in your program, but to help you do it yourself. But before we can do that you have to know what te problems are. | |
Re: You have my sympathies on your job loss. A lot of companies are screwing over their older works for the very reasons you suggest. And the IT field is not immune. I've heard a lot of horror stories about age discrimination in the IT industry. Anyone over about 25 is … | |
Re: Do you want managed or unmanaged code. Its pretty easy with unmanaged code -- just google for ODBC. I'm not sure how you can do it with c++/CLR or C# programs. | |
Re: >>can anyone give me their explorer.exe and explorerframle.dll ? (64bit Can I? Yes. Will I? No. Reinstall the operating system. | |
Re: If you are USA citizen or legal immigrant then join the US military. They will give you all the free training you will want. Most colleges and universities in USA have Cadet programs that let you attend college full time and give scholarships to help pay for tuition etc. I … | |
Re: [code] void City::setNextCity(City city) { nextCities->push_back(&city); }; [/code] You can't do it like that because the parameter is a copy of City class, and will be destroyed as soon as setNextCity() exits. You need to make list own all the memory so that it doesn't rely on anything outside of … | |
Re: What you want is a character array [icode]char buffer[255];[/icode] That declares an array of 255 characters. c++ also has a std::string class, but you can not use that with SqLite database. You have to be careful about allocating new memory in a DLL. Memory allocated in a dll with new … | |
Re: Post them in Business Exchange --> Looking To Hire. >>I'm also a social media geek with a good sense of humor. Can I stay? No -- we don't allow people with a good sense of humor here. Go away :) (Just kidding) | |
Re: Does Tom Hudgson = Glass Joe? Must be nice to get paid for playing games :) Do you know if its available on MS-Windows 7? Or just PSN and Xbox Live? Oh well, its probably too difficult for an old man like me anyway. I have yet to play Donkey … | |
Re: Making the file "read only" will NOT prevent an external application or the user from changing or deleting it. It mearly makes it more inconvenient. External applications or the user can always change the file permissions to read/write and either change the file's contents or delte it. If you want … | |
Re: The first line just declares a variable of type std::string The second line causes all keyboard input up to the '\n' (carriage return) to be sent to the string object. So if you typed "Hello World" <Return key> then the string subChoice would contain "Hello World". Copy and paste this … | |
Re: You are wasting your time and efforts trying to optimize that. There are only a few clock ticks difference between the two, and any optimizing you do with that will not even be noticable. Concentrate first at the function level -- do some profiling to see where the bottle necks … | |
Re: One way is not to Sleep() for so long [code] while(true) { Sleep(300); // sleep 30 seconds if( time to waik up) break; } [/code] | |
Re: Welcome to DaniWeb. Make sure you are familiar with the [URL="http://www.daniweb.com/forums/faq.php?faq=daniweb_policies"]Rules[/URL] because you will get into trouble here if you don't write in full English words, such as "you" instead of u. >>Do not write in all uppercase or use "leet", "txt" or "chatroom" speak | |
Re: [URL="http://www.gidnetwork.com/b-56.html"]Don't use gets()[/URL] Read that link -- it contains a lot of good-to-know dos-and-don'ts. | |
Re: Also maybe your comnputer has too little RAM. It needs at least 2 gig. Check the amount of free hard drive space available. The OS will get very slow if the hard drive is nearly full. | |
Re: What version of MS-Windows? The program has to have permissions to start services. | |
Re: Programmers use [URL="http://en.wikipedia.org/wiki/Include_guard"]code guards, sometimes called include [/URL]guards, to avoid the problems with double inclusions. You will find them used in almost (if not all) the standard header files that are installed with your compiler. When used, they would prevent the problem like the example presented by evstevemd, above. | |
Re: You mean like this? [code] #include <conio.h> #include <iostream> using std::cout; using std::cin; int main() { char c; while(true) { cout << "Enter a character\n"; c = getche(); if( islower(c) ) cout << "\nLower\n"; else cout << "\nNot lower\n"; } } [/code] | |
![]() | Re: Welcome to DaniWeb. For readers who are not from USA, AZ is the abbreviation for the state of Arizona, home of one of the World's Greatest Natural Wonders, the Grand Canyon. |
Re: No. Windows win32 api functions require a 32-bit compiler. Turbo C is a 16-bit compiler. Come into the 21st century and get either free Code::Blocks or vc+ 2010 Express. |
The End.