15,300 Posted Topics
Re: convert the strings to a have fixed-length fields [code] 7379->65535->65535 7315-> 5->65535 [/code] The the above, just to a simple comparison ![]() | |
Re: look at [url]www.microsoft.com[/url] for [URL="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dllproc/base/createthread.asp"]CreateThread[/URL]() win32 api function. It looks like a lot of parameters but you can leave most of them 0. I don't know if you can use the same stream object between threads or not (not sure if they are thread-safe). Even if they are, the two … | |
Re: >>"MESSAGE ""%s""\r" The reason this doesn't work the way you want it is because that is a standard way of concantinating string literals and the compiler will just make one string out of it. char str[] = "Hello " "World" is the same as this char str[] = "Hello World" | |
Re: [QUOTE=Narue]Sorry, but you wore out your code. The only way to fix the problem is to print the source out and then type it all back in fresh. This also happens when you let code sit too long and it starts to rot..[/QUOTE] :cheesy: :cheesy: :cheesy: you really should have … | |
Re: >>Now my guess is that the first block of code uses more memory at any given moment than the second one In the second example, a good optimizing compiler will notice that it only needs to allocate space for one std::string object and reuse this memory on each block entry. … | |
Re: No there is no shortcut because changing the color is an os-specific function and ansii standards try to stay clear of those issues. -- but you might be able to write your own ofstream overloaded function that will accomplish that. | |
Re: In c and c++, char is sort of a misnomer -- it is meant to hold more than just characters, it is in fact a small one-byte integer and can be used just like integers of other sizes. unsigned char has a range of 0 to 255 (see limits.h for … | |
Re: you still have several 16-bit c/c++ compilers available: Turbo C/C++, Watcom and Microsoft Visual C++ Version 1.52C. The M$ compiler is difficult to find, but the Borland compilers can be easily downloaded free from their web site. The Watcom compiler is also free, but I'm not sure where to get … | |
Re: just open the file for writing, then output all user input to that file. Yes, you have to add additional code to do that. No, you can't have cout and cin do two things at the same time (write/read to/from the screen and write to a file too). | |
Re: See any of [URL="http://www.google.com/search?hl=en&q=how+to+write+a+dll&btnG=Google+Search"]these google articles[/URL]. Many of them are for VB, but you can just ignore that part and read about how to write the dll. One important point: memory cannot be allocated in a dll and deallocate it in the calling application. Special non-ansi-standard functions such as GlobalAlloc() … | |
Re: The error is telling you that you are attempting to pass a pointer to a function, and the 1st parameter is supposed to be a float. Maybe you meant to code like this so that it calls giveX() which returns the float. [code] glVertex3f(pA.giveX(), pA.giveY(), pA.giveZ()); [/code] [edit]Sorry Dave -- … | |
Re: depends on the operating system. For ms-windows, I use CreateThread() and CreateMutex(). see MSDN for details. | |
Re: simple -- just typecast the float to an int. All decimals will be dropped, nothing rounded with this method. [code] float f = 12.345; int i = (int)f; [/code] | |
Re: I think you're c++ program will have to change fonts before beginning to output the text. The font used by the c++ console program is not the same font that the IDE editor uses. The IDE does not use cout or other console output functions to write to the window … | |
Re: offhand, I'd say you don't have a complete installation of the compiler. Attached is a bitmap of the bin directory on my computer. Yours should be similar. | |
Re: you are confusing the ascii value of '3' (numeric value is 53) with the binary value of 3 (decimal value of 3). Look at an ascii chart and it will show you the ascii values of all 255 possible values that can be contained in unsigned char. If you want … | |
Re: works ok with Dev-C++ (version 4.9.9.2 which uses gcc), just had to add getchar() after the scanf() to flush the '\n' out of the keyboard so that I could see the results before the program terminated. | |
Re: The best way to learn C is buy an Introduction to C book because none of the online tutorials are very good. all you will get online are bits and pieces -- a book will give you a thorough introduction. But say clear of the Dummies series -- not much … | |
Re: In addition, if the file is NOT one the current working directory the program may have to change the current working directory to where the file is. There are a few operating systems where there is no concept of "current working directory", in which case the program has no choice … | |
Re: FILE (all caps) normally refers to C file i/o functions, such as fopen(), fgets(), fread(), fwrite() and several others. The word "file" (all lower case) generally describes what is actually stored on the disk -- each file has a filename and size. >>Secondly, does the definition of "stdin" include this … | |
Re: Can't you just simply use std::vector? [code] vector<bool> array; [/code] It will grow as needed. | |
Re: use the depends.exe that is in the vc++ 6.0 install bin directory to find out what dlls are required, then install those dlls with your program. You must take care not to overwrite newer versions of the same dll that is on the target machine. If you use an install … | |
Re: You don't need that list at all. you alreay have map which you can use to map strings with their counts. Add the words to the map when read and you will not need the list at all. Also, the loop to read the file can be coded better [code] … | |
Re: If you have learned about liked lists then using a linked list to hold the words and their counts would be more efficient. But if you haven't learned about them yet, you can just use a simple array of a very large number -- say an array big enough to … | |
Re: VB is generally considered a toy. OK for your own personal enjoyment but not very well supported in commercial world. Managed .NET may change that perception in the future. | |
Re: >>I know sizeof(struct baseball) = 16. Not necessarily -- that is compiler implementation dependent. Just because one compiler says its 16 doesn't mean it will be the same for all compilers. The sizeof(Yankeys) is the sizeof(struct baseball) * numer of elements in the Yankeys array. And the number of elements … | |
Re: what's wrong with the Dev-C++ compiler? It compiles both C and C++ ok. If you want it to compile C only, then make the filename extension *.c instead of *.cpp Myself, I like Microsoft compilers better because they have better debugging tools. You can still get VC++ 2005 Express for … | |
Re: see [URL="http://www.winprog.org/tutorial/"]this[/URL] tutorial | |
Re: because the keyboard buffer still contains the <Enter> key -- you need to flush that out. One way is like below, which will remove up to 3 keys. [code] char inbuf[4]; menu(); fgets(inbuf,sizeof(inbuf),stdin); //scanf("%c",&choise); choise = inbuf[0]; [/code] | |
Re: #include<iostream.h> #include<string.h> #include<fstream.h> You must be using an ancient c++ compiler -- maybe Turbo C++? If you want to learn c++ language you will have to toss that compiler into the bit bucket and get a modern one --[URL="www.bloodshed.net"] Dev-C++[/URL] is a good one. | |
Re: what's the difference between [b]deep[/b] copy and [b]shallow[/b] copy or [b]not so deep[/b] copy :rolleyes: | |
Re: Problem 1: [URL="http://msdn2.microsoft.com/en-us/library/3y1sfaz2.aspx"]__declspec (dllexport)[/URL] is only used in the dll to identify those functions or c++ classes that need to be visible to the outside world (i.e. application program or other dlls.). use __declspec (dllimport) in the function prototype in application programs. [code] int __declspec (dllimport) foo(); // function prototype … | |
Re: [code] #include <stdio.h> int x; int y; int a,b,c; int main() { // put your code here return 0; } [/code] | |
Re: There are probably a number of ways to solve that. The solution I took was to create another listener thread. The main program thread sends a message to this listerner thread every keyboard and mouse event. The listner thread waiks up from Sleep() every minute and checks its input queue. … | |
Re: that is NOT a c++ program. Its a C program. What are the errors? Post them. And you really really need to develop a decent program coding style. Starting everything at the beginning of the line is just plain lazy and horrible. Nobody is going to read that stuff. | |
Re: [QUOTE=Te'DDy]in here the words j appear second time again in my words series and o also. may be it might be better to check not to repeat the words.So how can i do?[/quote] check the array to see if the char is already in it. If not, add it to … ![]() | |
Re: the unsigned char data type has a range of 0 to (and including) 255. So all you need is an int array of that size to count the number of occurences of all characters. Initialize the array to all 0s then use the char itself as the index into the … | |
Re: [QUOTE=Cool Nanu]Yes i think thats correct but to help someone is not wrong[/QUOTE] True -- but the OP didn't ask for our help, just stated a problem.:rolleyes: | |
Re: you can find the exact example of that in Microsoft Scribble tutorial. See [url]www.mscn.microsoft[/url] and search for "Scribble Tutorial". It will show how to just draw straight lines but might be expanded to include other shapes too. | |
| |
Re: [code] for ( i = 0; i < n; ++i ) { for ( j = i; j < n; ++j ) [/code] that is a waste of cpu cycles because it compares the first array element with itself. array[i] is the same as array[j] [code] for ( i = … | |
Re: neither -- If you want to learn C then write console programs for the PC because PDA and Palm do not support the full set of C language. And because PC programs are a whole lot easier to debug. | |
Re: you missed the point. Create only ONE structure that contains the weather data. Then instantiate an array of 12 of these structures. [code] struct weather { int rainfall; int high_temp; int low_temp; }; weather array[12]; [/code] In the above, array[0] = January, array[1] = February ... array[11] = December. In … | |
Re: you probably need to set the baud rate, stop bits, data bits, and parity. See MSDN about [URL="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/devio/base/communications_resource_configuration.asp"]how to configure the port[/URL]. | |
Re: Assuming MS-Windows os, use [URL="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vclib/html/_crt_setlocale.2c_._wsetlocale.asp"]SetLocal[/URL] and the os will make the conversion for you when the values are read from the file. | |
Re: you need to know a bit about [URL="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vccore98/HTML/_core_mixed.2d.language_programming.3a_.overview.asp"]mixed language programming[/URL] and C calling conventions. | |
Re: >>If I want to generate random numbers between -1 and 1 Why? The only number between -1 and 1 is 0. -1, 0 and 1 are all integers, there are no fractions in integer math. rand() returns an integer. So if you want a float return value, such as 0.123 … | |
Re: iostream.h is obsolete. Use <iostream> (without .h extension). The iostream class was changed somewhat. If you are using an ancient compiler that does not have <iostream> then you should upgrade to a newer compiler. Any attenpt to use iostreams with ancient compilers will teach you nothing at all about modern … | |
Re: [QUOTE=Forsal]Hi everybody Can you please explain me the weakpoints of c++ language?[/quote] there are none. The language will allow you to do anything you want to your computer -- even burn it up if you want it to. [QUOTE=Forsal]I think it is very difficult to create GUI in C++, isn't … | |
Re: If you are writng a C program, use fgets() to get the string from the keyboard because it will not permit buffer overflow. Your version of the function has the same problem as gets() -- it will just scribble all over memory when you enter more characters than can be … |
The End.