15,300 Posted Topics
Re: The code you posted requires the program to read just 3 lines of text. What happens if there is only 1 line, or 20 lines, or 1,000 lines? You certainly don't want to have to count the number of lines before reading the file. A solution is to 1. Create … | |
Re: >>strcpy(address,NULL); strcpy() hates that statement because it expects a valid pointer as the second argument, not NULL pointer. If all you want to do is initialize the array to 0 then use memset(), e.g. [icode]memset(address,0,sizeof(address));[/icode], assuming that address is not a pointer. Or you can just simply do this: [icode]address[0] … | |
Re: I think pipes will work for you. [URL="http://www.google.com/search?source=ig&hl=en&rlz=1G1GGLQ_ENUS397&q=popen+and+mfc&aq=f&aqi=&aql=&oq="]Here[/URL] are a few links you might want to read. | |
Re: Whether you can find it with google or not will depend on the problem you want to solve. The source code for most programs are [URL="http://en.wikipedia.org/wiki/Proprietary_software"]proprietary [/URL]and are not posted anywhere on the internet. | |
Re: Not all DLLs have to be registered. Just because it uses COM doesn't mean it has to be registered. Just put it in one of the folders in the PATH environment variable. | |
I get this error for every thread I click in the c++ forum. C forum seems to be ok. | |
Re: What are the errors and warnings?? We can't read your mind or see your computer, so you have to be specific and tell us. | |
Re: What operating system and what compiler ? The easiest way to capture the Enter key would be to use the non-standard functions in conio.h, but your compiler may or may not support that. | |
| |
Re: GUI and RS232 serial port program are unrelated. Here is a list of the [URL="http://msdn.microsoft.com/en-us/library/aa363194(v=vs.85).aspx"]Windows Communications Functions[/URL]. Start out by calling CreateFile() to open the serial port, then BuildCommDCB() to set up the port configuration (stop bits, data bits, parity, etc). Then ReadFile() to read from the port and WriteFile() … | |
Re: >>And it outputs junk (mainly numbers like -147, 70, 8, 10), etc. Exactly -- binary files can not always be read, which is why they are called binary files. You have to know how the binary file is formatted before you can make any sense out of them. For example, … | |
Re: The problem is that p will be pointing to some out-of-range memory location and that has nothing at all to do with whether its of type T or not. You will get the same error if you try to do the same thing in a simple C program. C and … | |
Re: Any salary difference will be neglible. You need to talk to a school couseler at the college you want to attend to find out what courses are required for each of those degrees. A degree in CS will probably require more math than the degree in IT. | |
Re: Stormy Norman [quote="Norman Schwarzkopf"]It doesn't take a hero to order men into battle. It takes a hero to be one of those men who goes into battle. [/quote] [quote="Norman Schwarzkopf"]He <Saddam Hussein> is neither a strategist nor is he schooled in the operational arts, nor is he a tactician, nor … | |
Re: SqLite doesn't throw exceptions, it just returns errors. You will have to change SqLite source code to make it throw exceptions like what you want. You have all the source code so you can change it any way you like. | |
Re: Yes they should return an int, but the author probably omitted that just to simplify the code and illustrate the intended problem. | |
Re: You could try [URL="http://lmgtfy.com/?q=c%2B%2B+color+codes"]this[/URL] or [URL="http://lmgtfy.com/?q=c%2B%2B+color+text"]this[/URL] to get examples | |
Re: have you tried [URL="http://msdn.microsoft.com/en-us/library/3e22ty2t(v=vs.80).aspx"]SetLocale()[/URL] | |
Re: [URL="http://lmgtfy.com/?q=duplex+communication+using+c"]Did you try this[/URL]? | |
Re: CString has a Format() method that works exactly like sprintf(). Simplify your code like this: [icode] CString m_strFileName.Format("%02d/%02d/%4d %02d:%02d:%02d", t.wDay,t.wMon,t.wYear, t.wHour,t.wMinute,t.wSecond); [/icode] Adding 5 to t.wHour can easily make t.wHour exceed 60. | |
Re: don't use strtok() because it will put 0s in the std::string buffer, invalidating that buffer. Instead, use std::string's find() method to locate the spaces, the substr() to extract the characters. | |
Re: functions and structure in time.h will give you that information. [list=1] First put the day, month and year in a struct tm structure. Then call mktime() to populate the rest of the structure. tm_wday contains the day of the week. | |
Re: >>but it doesnt work What does that mean??? lines 13 and 14 could be both replaced by one line: jl end_if | |
Re: depends on the functions you are using to get the files in a folder. On MS-Windws using FindFirstFile() and FindNextFile(), see the fields in the [URL="http://msdn.microsoft.com/en-us/library/aa365740(v=vs.85).aspx"]WIN32_FIND_DATA[/URL] structure. dwFileAttributes will tell you whether its a file or a folder. Similar on *nix using opendir() and readdir() functions. | |
Re: The while statement on line 19 is incorrect -- you don't need numOfInput. To read the entire file the while statement should be constructed like this: [icode] while( inStream>>deweyDecimal ) { // blabla } [/icode] But that will only read one word. If each line in the file contains more … | |
Re: You can use [URL="http://www.codeblocks.org/downloads"]Code::Blocks[/URL] on both MS-Windows and *nix | |
Re: >>while (a!='q' || a!='Q') Use && operator instead of ||. Read it as "while a not equal to 'q' and not equal to 'Q'" >>expected before "return" I think you will need a semicolon at the end of that line too because its the end of a do loop | |
go to c++ forum and look at the last date and reaction columns. They are just wrong. For example the thread "Different Heaps" shows last date was 37 minutes ago and Reaction shows 1 post. Now click on that thread and look at the time of the last post -- … | |
Re: text is a pointer to a character arrray. The star in front indicates dereference of the character. So if text == "Hello", then *text is looking at the first letter, 'H'. C strings are always terminated with the NULL character 0, or '\0'. The while statement as written is poorly … | |
Re: Just call fgets() to read the first line before starting the loop on line 32. I think this would be a lot easier if you used fgets() to read every line, then parse it by using strtok() [code] char buf[255]; fgets(buf, sizeof(buf), in); // just ignore the first line while( … | |
Re: Depends. What operating system? For MS-Windows, do you want to use pure win32 api functions? If yes, [URL="http://winprog.org/tutorial/"]here is a tutorial[/URL]. But there are a lot easier ways to write gui programs nowdays. Two of them is CLR/C++ Windows Forms, and C# instead of C. If you are thinking *nix, … | |
Re: >>Am I too old to do some courses and become a programmer??? Not unless you are over 100 years old :) I didn't start programming career until I was in my early 40s. | |
Re: >>if( (ch-48) >= 0 && (ch-48) <= 9) replace that with: [icode]if( isdigit(ch) )[/icode] | |
Re: >>Update: The professor in question has been reported and is now banned from taking any more classes. hallelujah! :) | |
Re: >>strTemp.Format(_T("item"), i + 1); Format() function is very similar to sprintf() -- you need to add %d if you want the string to contain the value of i+1.[icode]strTemp.Format(_T("item %d"), i + 1);[/icode] | |
Re: To complicate it a little more, the main program and DLL each have their own heaps (and memory managers), and that's why memory allocated in a DLL can not be released in the main program (or another DLL) and vice versa. I'm not sure if shared libraries on *nix work … | |
Re: That's not possible. Why? One reason is that getline() doesn't know, or care, what the size of the command window is. It reads everything up to the '\n', or some other character you specify. ![]() | |
Re: >>if ( 'a'=!'e' || 'a'=!'d' || 'a'=!'E' || 'a'=!'D') remove the quotes around variable a [icode]if ( a=!'e' || a=!'d' || a=!'E' || a=!'D')[/icode] and not equal is != You want to use && and operator, not or operator. Using or in that statement will cause it to always return … | |
Re: >>operand[i]!='+' || operand[i]!='-'; Use && operator instead of ||. Read the statement aloud to yourself -- "do while operand not + and while operand not -. | |
Re: lines 14 and 17 are just showing you two different ways to do the exact same thing. | |
Re: >>1- read files from the directory, avoiding sub-directories (along w/ _chdir) That means to use directory functions to get the names of all the files in a directory. How to do that will depend on what operating system you are using. [list=1] [*]MS-Windows: FindFirstFile() and FindNextFile() [*]*nix: Opendir() and ReadDir() … | |
Re: >>You have to include windows.h, No you don't. including windows.h will make a simple console program carray around a lot of useless and unnecessary bagage. Just include cstdlib (as previously mentioned) or stdlib.h. | |
Re: You don't need that loop at all -- just set up al, eax then call [icode]rep scasb[/icode] to search for the string length | |
Re: ShellExecute() is declared in Shellapi.h, not windows.h | |
Re: try using [icode]if( inHandle.is_open() )[/icode] The problem might also be that the file does not exist in the current working directory. | |
Re: Your program seems to be doing it correctly. But I don't see where you declared variable named sum. | |
Re: >>My friend needs a program that will: That's nice -- now when are you going to write it for him? We certainly will not without a lot of $$$$. |
The End.