299 Posted Topics
Re: [I]Token plug for ported GNU compilers.[/I] Get the MinGW/MSYS if you're using Windows, but want to run on the command line. [url]http://sourceforge.net/projects/mingw/files/[/url] Grab the link near the upper middle that says "Looking for the latest version?" Get DJGPP if you are actually using honest to goodness DOS 5.0 - 6.22 … | |
Re: There are two loops in the bubble sort. With one loop, essentially, you're only doing one pass, sorting the highest value to the top, but neglecting the others. This may prove useful: [url]http://www.codecodex.com/wiki/Bubble_sort[/url] Also, you may want to change that i==5 to i==4. When i equals 5, you'll be starting … | |
Re: I was going to roll my own, but this works just fine. [url]http://www.fredosaurus.com/notes-cpp/algorithms/string2int-ans.html[/url] Adapt it to eliminate the [B]bool[/B]s if you need to, but the code should work just fine. | |
Re: AllocConsole is your friend. [url]http://lmgtfy.com/?q=allocconsole[/url] | |
Re: Well, you can do a private Wi-Fi network secured with Pringles cans (you think I'm joking). Or you can set up laser transceivers - effectively fiber-optics without the cable. Unfortunately, ANYTHING can upset the signal. Anything. Like squirrels. Rain. Kites. Obese persons on ladders. Anything. | |
Re: Program 1: [LIST=1] [*]Prompt the user for the file size in KB of the first file. [*]Scan for keyboard input and store in a variable. [*]Multiply by that by the number of bytes in a KB. Multiply again by number of bits in a byte. [*]Prompt the user for the … | |
Re: Two possibilities. A. roll=int(num*11)+2; //Just reduce the 12 to 11 and add 2 instead of 1. B. rewrite it to roll a single die, save the value, then roll again. | |
Re: What you want to do is likely above your present ability. (For now.) I'm telling you this kindly. However, you have asked a question, and I will answer it. (Who knows, this might be the start of a wonderful new world of socket programming for you.) First, since you are … | |
Re: OK, look at your main function: [CODE]int main(){ int option =0; bool exit = false; while(!exit) { displayMenu(option); switch(option) { case 1: doTaskA(); continue; case 2: doTaskB(); continue; case 3: doTaskC(); continue; case 4: howMany(); exit = true; break; default: printf("Incorrect selection. Try again.\n"); continue; } } return 0; } … | |
Re: I want to make a hoe joke so very badly... So... nobody brought this up, but [B]libPThread[/B] is PRIMARILY a [B]Linux[/B] library being "[B]POSIX Threads[/B]." There is a Windows implementation available and can be installed as part of [B]MinGW[/B] using it's Get command (i.e. [B]mingw-get[/B], the command line apt-get substitute). … | |
Re: Very nice. However, somewhere along the line, in the zoom functions, times became an asterisk and center became a cent. | |
Re: Let's start with the basic psuedo code: [CODE]X=2 WHILE X IS LESS THAN MY_NUMBER IF MY_NUMBER MODULO X IS 0 THEN RETURN FALSE ELSE INCREMENT X BY 1 LOOP RETURN TRUE[/CODE] Now, that's fantastic and all, but it's very inefficient. After 2, there aren't anymore even primes. Let's make our … | |
Re: Hm... just for sanity's sake, make this change: [CODE] org 0x000 goto Start org 0x005 Table_ addwf PCL,f dt 0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f [/CODE] I've got a little background in PICs. I'll look over this more when I get the chance. | |
Re: [B]string[/B] is a C++ type. You'll want to convert your code to use C++ instead. [B]string.h[/B] is a C header file and doesn't provide that. If you don't want to use C++, you should use character arrays. And instead of acountry[j]=arr[i]; you would use [B]strcpy(&acountry[j].code,&arr[i]);[/B] | |
Re: Well, to start, setup a space for your string for 11 bytes(trailing zero) and put that in your data section. Also, put your string prompts into the .data section. (i.e. "Enter 10 character string: ") Then, in your main program, you print the prompting string (you know how to use … | |
Re: [COLOR="Red"]Without generating the data myself I'm kind of limited in what I can do to help. However, [B]chi_squ_end[10000000][/B] bugs me. A lot. And being a double type, on a 32-bit system, that thing's 80 Million bytes huge. May I humbly suggest moving outside and before the main block. This takes … | |
Re: Well, for starters, you want to put your code inside the [B][ CODE ][/B] blocks. It preserves the formatting. Looking at your code isn't as much fun without indentation. And... and... you have used GOTO. [B][COLOR="Red"]And you have sinned.[/COLOR][/B] Just kidding. (But you may want to look into ways around … | |
Re: WaltP and Deceptikon are right. And I can tell they're ready to lose their patience. It's a simple fix, but to a new coder, it may not be obvious. See this line of code? [CODE] printf( "Enter gallon used (-1 to end): " ); scanf( "%d", &gallon); [/CODE] This is … | |
Re: Multi-threaded/process programs for starters. Mutexes, Semaphores, all the yummy goodness. Then there's windows, messages, callbacks. You know. The stuff they don't teach you in college until MAYBE the senior year. Even then, my Operating Systems class never touched GUIs let alone straight from the OS API. This is the good … | |
Re: File->New Project->Static Library. It will create an [B].a[/B] file. Reference that project in your linker libraries in your next project. | |
Re: These is not the article you are looking for. (Especially Method 3.) [url]http://www.codeguru.com/cpp/i-n/network/networkinformation/article.php/c5451[/url] | |
Re: That's some-funny looking code in the first program. It looks like one programmer wrote a "test port" program and a second one expanded it into a http client. In the header, it looks like we're using an http client with a single parameter. [CODE]/*** "GET <resource> HTTP/1.0\n\n" (the second newline … | |
Re: Well, this goes back to 16-bit addressing (as revealed by your use of [B]near[/B]). In 16 bits, the size of an int (being 16 bits) is 2 bytes. You increment it twice. But the compiler knows it's an int pointer, so it increments it by 2 each time. So you're … | |
Re: Use the [B]|CODE|[/B] blocks to keep your code lined up straight. This is the code with indentation, spelling corrections, and consistency edits. The code is functionally the same. [CODE]#include<stdio.h> #include<conio.h> #include<string.h> #include<stdlib.h> int main(){ FILE *A, *B; char another; int choice; struct student{ char name[40],f_name[40]; int age,clas; long int rnum, … | |
Re: I'm not seeing why you want to use A*. Have a look at these instead. [url]http://en.wikipedia.org/wiki/Flood_fill[/url] [url]http://tog.acm.org/resources/GraphicsGems/gems/SeedFill.c[/url] | |
Re: @Lerner: ditto. @Ancient Dragon: Also ditto. Cangan's code is a starting point. Nothing more. And that's what was asked for. I'd replace the [B]if[/B] statement with a [B]switch/case[/B] block that catches vowels. Lastly, the instructor says to use cin, but to break on the return. Cin accepts until return, but … | |
Re: You have a carry you're not taking care of after you parse everything. Try putting in leading zeros and see what happens (it should work). However, that's not how you want to do it. You'd need to insert the carry bit in the front and push the rest of the … | |
Re: Well, look at what's happening to your pointer and it'll let you know. I modified your code to do this. [CODE] #include<stdio.h> #include<conio.h> void main() { int arr[3]={2,3,4}; char *p; //clrscr(); p=arr; printf("*p:%d, p: %ld\n",*p, p); p=(char*)((int*)(p)); printf("*p:%d, p: %ld\n",*p, p); p=(int*)(p+1); printf("*p:%d, p: %ld\n",*p, p); //getch(); }[/CODE] It gave … | |
Re: Hi, Yordan! Welcome to Daniweb! Hope you can get your bar code scanner done. Myself, I steer clear of VB, but to each his own. Happy coding! | |
Re: Oh hey! You got bots here too? I thought I left those behind in Webmaster Talk Forums. | |
Re: Welcome to DaniWeb. The only stupid question is a question un-asked. Or about Visual Basic. Happy Coding! | |
Re: Be patient. It's still processing. It doesn't print until all the random numbers have been generated. Those sometimes take a while. Especially when there are a lot of them. Compiled code with G++. Ran with CPU under moderate load. Finished in 14 seconds. I'm not seeing any problems. | |
Re: OK, so it sounds like you want to put a dot on the screen and get your test subject to look at it even though their eyes are wired not to. Is that the gist of it? If you're going to use C++ and you're pretty new to it, well... … | |
Re: This maybe useful to help you understand: [url]http://en.wikipedia.org/wiki/MSDOS#Legacy_compatibility[/url] [url]http://en.wikipedia.org/wiki/Microsoft_Windows#History[/url] [url]http://en.wikipedia.org/wiki/16-bit_application[/url] [url]http://en.wikipedia.org/wiki/32-bit_application[/url] [url]http://en.wikipedia.org/wiki/64-bit_application[/url] As you can see, Windows follows two family trees. The upper left tree is based on MSDOS, which is a 16-bit operating system. It required special software to allow programs to run in 32 Protected Mode. Windows 95, … | |
Re: This sounds suspiciously like the problem Gourav1 posted last week. I provided an answer that should satisfy. See his post here: [url]http://www.daniweb.com/software-development/c/threads/407089/1737797#post1737797[/url] See my response here: [url]http://www.daniweb.com/software-development/c/threads/407089/1738493#post1738493[/url] Gourav1's question was directed at text animation. However, a graphical solution could easily be adapted. When drawing your image, draw by columns, and … | |
Re: [CODE] char numberAsString[6]; char numbers[][]= {"Zero","One","Two","Three","Four","Five","Six","Seven","Eight","Nine"}; do{ printf("Enter a number (0-9): "); scanf("%d",&number); }while(number<0||number>9); strcpy(numberAsString, numbers[number]); printf("You entered %s.\n", numberAsString); [/CODE] | |
Re: Gourav1, you are now my new favorite poster. You give us problems from 15 years ago. To check and debug your code, we'd need DOSBox and an ancient (and completely legitimately obtained) copy of Turbo C++ 4.5. Epic win. [url]http://www.go4expert.com/forums/showthread.php?t=21153[/url] Have a look at this page. Run all the examples. … | |
Re: Threads can return values. Which API are you using? Here's an example for PThreads: [url]https://computing.llnl.gov/tutorials/pthreads/#Joining[/url] Since the thread function is a void pointer, it can point to any piece of data you like, and is retrievable with the pthread_join function. For Windows, you can use the GetExitCodeThread function. [url]http://msdn.microsoft.com/en-us/library/windows/desktop/ms683190(v=vs.85).aspx[/url] | |
Re: Used shared memory. This will help you get started. [url]http://www.cs.cf.ac.uk/Dave/C/node27.html[/url] [url]http://digiassn.blogspot.com/2006/07/cc-unix-ipc-shared-memory-example.html[/url] | |
Re: How many copies of MinGW do you have on your system? If you're using Dev C++, then that makes at least one. Reference: [url]http://cboard.cprogramming.com/cplusplus-programming/111216-compiler-problem.html[/url] Make sure to use a recent copy of MinGW and update often. I would also include a bare-minimum MSYS including Make. | |
In my wayward youth, I learned a little bit of inline assembler in Turbo C. And that was fun. Then I got into DJGPP which came with GCC and Bell Syntax. And it was confusing. And I gave up. Fast forward 12 years. I'm 30, finishing a bachelor's in CS. … | |
Re: Let's start with the basics. You're going to print out a set of characters in an array on a screen. You're going to jiggle the characters by a wavy function, let's say the sine function. You're going to output in color. Each character in the array has a color assigned … | |
Re: @WaltP: Those are very good points, and I agree. @Yamna Midhat: OK, some things I see after some minor debugging. [B]Line 105[/B]: Missing ampersand. Change that to [CODE]scanf("%d",&cos);[/CODE] [B]Line 336[/B]: Missing ampersand. Change that to [CODE]scanf("%d",&item_no);[/CODE] At delet_selectd(): you're not checking current->next to see if it's allocated yet. This will … | |
Re: [B]try[/B] is a keyword. Also, have you already allocated the memory space for character array pointed to by *[I]filename[/I]? (By allocate, I mean like [B][I]char buffer[20];myFilename=(char*)buffer;try(myFilename);[/I][/B] or [B][I]myFilename=new char[20];try(myFilename);[/I][/B] | |
Re: I haven't gotten into CLR C++ yet, but I'll take my best shot. [CODE] MyDataType_Class ^myFunction(String someName="",int someID=0){ MyDataType_Class ^new Person=gcnew MyDataType_Class(); Person->id=someID * 2; //Multiply by 2 just because Person->name=someName; return Person; } . . . void SomeOtherFunction(){ MyDataType_Class ^thisPerson=myFunction("Runcible Spoon", 21); . . . } [/CODE] | |
Re: I can think of two ways to do this. (Also, get rid of the return j. It returns from the main function and exits the program. Get rid of the printf(j) at the bottom. Why do you have it?) [B]First[/B]: using arrays. Since you're using characters 7 lines tall, create … | |
Re: Wait for the screen to refresh. See if your API will let you do that. What API are you using anyway? | |
Re: So... I thought, how would I do this the RIGHT way in C? No STL at all. Hm... Arrays, well, they're kind of passe'. Linked Lists are the bees knees. Or something. I was thinking about using BSTs, but wasn't sure at what point to implement leveling/balancing. I decided that … | |
Re: @abhijit d: Um... dead thread is dead. Y u no let thread stay dead? |
The End.