1,118 Posted Topics
Re: If you are using the GNU tools, you can say: [inlinecode]gmake -n -p[/inlinecode] to print the internal database used to compile without actually compiling anything. Also, you can get the GNU compiler to give you dependency information about a specific file: [inlinecode]gcc -MM foo.c[/inlinecode] prints all the non-system files that … | |
Re: Your limit is an [B]int[/B], which is too small to hold the number you have put in it. (Your compiler should have complained about this.) Try using a [B]long long[/B] or somesuch. Start [B]runningcount[/B] at 2, not one. Your [B]primeChecker()[/B] function is fine, but it will be slow. Hope this … | |
Re: Google is your friend. Try [URL="http://linux.about.com/library/cmd/blcmdl3_dlsym.htm"]this[/URL]. Good luck. | |
Re: No one. Please use google. Sorry to be rude, but the only reason to code this in assembly is for homework. The game is not that hard so you can do it yourself easily. | |
Re: The [B]int()[/B] operator should return [B]sizeInInches()[/B]. Also, watch it, your [B]sizeInInches()[/B] function is not correct: you return the number of feet in inches but forget any extra inches there may have been in [B]inches[/B] before calling the function. Since you don't want to normalize or un-normalize, use a local variable … | |
Re: You are asking the wrong kind of question (please read the [URL="http://www.daniweb.com/forums/announcement8-2.html"]Announcements[/URL]) and in the wrong forum (this is C++ Software Development, not the Tech Talk forum). Please spend some time with your textbook, googling, and thinking about the concepts you have learned so far. I doubt your professor will … | |
Re: Forgive the apparent pun, but you need to observe the pattern of your image. For illustration I'll supply my own example image here: [code] [color=red]......[/color]ABCDEFGFEDCBA [color=red].....[/color]ABCDEF[color=green]...[/color]FEDCBA [color=red]....[/color]ABCDE[color=green].......[/color]EDCBA [color=red]...[/color]ABCD[color=green]...........[/color]DCBA [color=red]..[/color]ABC[color=green]...............[/color]CBA [color=red].[/color]AB[color=green]...................[/color]BA A[color=green].......................[/color]A [/code] There is a pattern to each line. The first pattern is that the number of red dots (representing … | |
Re: The problem is that [B]pos2[/B] is finding the same space character as [B]pos[/B]. Essentially you are doing this: [code] pos = string( "Hello, world!" ).find( " " ); pos2 = string( "Hello, world!" ).find( " " ); [/code] The same space is found each time. The find() function takes a … | |
Re: An integer is represented (by humans) thus: [inlinecode]1234[/inlinecode] 1 is in the thousands place 2 is in the hundreds place 3 is in the tens place 4 is in the ones place Each place to the left is times 10. So: 1234 div 10 is 123 R 4 123 div … | |
Re: The [B]strstr()[/B] function [inlinecode]#include <string.h>[/inlinecode] will return whether or not a given string contains a given substring. [code=C] char string_to_search[] = "Hello, world!"; char string_to_find[] = "world"; char *pos; pos = strstr( string_to_search, string_to_find ); if (pos != NULL) printf( "found it at index %d\n", (int)(pos -string_to_search) ); else printf( … | |
Re: [color=orange][B]interfacing with the console[/B][/color] If on Windows you'll have to use the (non-standard) stuff in <conio.h>. Just include the library file and compile. If on linux you'll have to use the curses library. There are various versions of it: [B]curses[/B], [B]ncurses[/B], and [B]pdcurses[/B]. You are sure to have at least … | |
Re: That was my first thought too, but I realized that very problem would occur. Having thought it over some the answer is embarrassingly obvious: just cut and paste the text. Hope this helps. | |
Re: Welcome to the world of programming. All I can say is: it gets better. The C++ compiler (especially with the STL) is not a very sympathetic complainer. Show us what you've done: algorithm, code, errors, etc. and we'll help you think your way through it. Don't feel bad or give … | |
Re: You're looking fairly good. 2. You are given an [B]istream[/B] named [B]inFile[/B]. You need to create two floats: one named [B]x[/B] and the other named [B]y[/B]. Remember that [B]cin[/B] is also an [B]istream[/B] (so you can use your file stream just like you use [B]cin[/B]). 6. Remember, 7.987... rounds to … | |
Re: Or you could just use the [B]strspn()[/B] function: [inlinecode]if (strspn( dnaStr, "AaTtCcGg" ) < strlen( dnaStr )) puts( "error in DNA" );[/inlinecode] | |
Re: Float types are just the hardware's floating point data type. Usually this is an IEEE single (4-bytes), double (8-bytes), or extended (10-bytes). The problem with these is that they [I]approximate[/I] numbers. Hence, they are not very exact. They lack precision and they are susceptible to the influences binary arithmetic. The … | |
Re: I'm not sure what you mean. Do you mean that you want to execute another exe from your program? You can do that using the [B]system()[/B] function or one of the [B]exec[/B] functions in [inlinecode]<unistd.h>[/inlinecode]. Hope this helps. | |
Re: Hey there, I've been playing around with a WSH script that could do it for you. However, I need to know, are you using XP? | |
Re: Everything happens when you hit the [Process] button. So add an OnClick method and inside that just check to see what value edit1.text string is, and set the other edit text strings appropriately. Good luck. | |
Re: [B]Siddhant3s[/B], please stop giving people code. Read the [URL="http://www.daniweb.com/forums/announcement8-2.html"]Announcement[/URL]. The purpose of the forum is the [I]help people learn[/I], not get us banned from schools. | |
Re: Whenever you read the word "structure" always think [B]record[/B] (or [B]class[/B], but you haven't gotten that far yet...). So create a record with a string for the person's name and some numbers for his birth date. Then, when reading the file, be careful to pay attention to the shape of … | |
Re: If I understand what you want to do correctly, you want to do something like an associative array or a map where the first array simply indicates what type of thing is in the second array? So: [inlinecode]if (keys[ n ] == "name") cout << "Name = " << values[ … | |
Re: Both your teachers are full of crap. Use ==. Keep in mind, though, that == is limited to an [I]exact[/I] match comparison and only returns bool. You can get a little more information back using functions like [B]string.compare()[/B]. Hope this helps. [EDIT] I should give a little more info. For … | |
Re: It sounds to me like your child process is misbehaving. May I ask which command you are executing? | |
Re: You have a good general idea of what you are doing. However, you need to pay attention to what [I]type[/I] of thing you are handling, and where your pointers currently point. In your [B]show()[/B] function you have improved some. Let me add some commentary that might help you: [code=C++] void … | |
Re: You can't. What you can do, though, is have another string with all your other data, which you use to copy the valid characters to from the original string. Once you find a punctuation character, print the second string using the function given to you, then use the second string … | |
Re: Your question is much too vague for me to help you. What is it you wish to classify? | |
Re: Please read the [URL="http://www.daniweb.com/forums/announcement125-2.html"]announcements[/URL]. If you can come up with a good idea of what you want to do and how to do it we can help you along. Post back with some (substantial) code. | |
Re: There is no way to do this without system dependencies. C++ doesn't know anything about the output device, so if you want to play with it you have to know something about it. It is possible to write your C code to choose to compile specific options depending on what … | |
Re: I recommend the [URL="http://gcc.gnu.org/"]GCC[/URL]. It comes with C and C++ and is fully standards compliant. If you want an IDE I'm not sure. Maybe someone else has a suggestion for that... | |
Re: Everything after [B]db[/B] is a byte. This sequence of bytes is obviously meant to be used as a character string, so everything in it is a character. 13, 10 is the ASCII character codes for CR and LF, meaning Carriage Return and Line Feed. In other words, it will print … | |
Re: Watch your fencepost conditions. [B]j[/B] can become negative. Try tracing your sort using this input: [code] arr3 = 1 3 7 2 9 0 5 j i temp = 3 [/code] Good luck. | |
Re: First, a short rant. Professors love to use stuff like this because it doesn't exist in real life and nobody will know how to help you (or help you cheat... but I won't do that). I had to go download all the stuff off of your textbook's website to learn … | |
Re: You have two problems that I see. The first is that you are using the struct tag without the struct keyword: [inlinecode]korifi *a[100];[/inlinecode] I think you meant to say this: [inlinecode]kdiktis a[100];[/inlinecode] The next problem is that you are throwing memory away: [code] root->a[s] = (kdiktis)malloc(sizeof(struct korifi)); // allocate big … | |
Re: I didn't know you could make applets using Pascal... Are you sure you aren't using Java or somesuch? Either way, remember that your substitution cipher is composed of two separate pieces of information: the code word and the remaining alphabet: [inlinecode] code word + remaining alphabet [/inlinecode] You can consider … | |
Re: No, the call to [B]fork()[/B] is correct --I see nothing wrong with it. You are aware that this is a *nix system function and it will [I]not[/I] work on Windows, right? I'm not sure what you are trying to do with the signal. Are you trying to make a pointer … | |
Re: I think this will do what you want: [code=Tcl] proc main {ip port} { set connection_to_server [socket $ip $port] puts $connection_to_server "Hello TCP-IP World\n" close $connection_to_server } main 127.0.0.1 6789 [/code] If you need your tcl script to be directly executable from the command line I'll need to know more … | |
Re: You are very close. You just need to add a couple of things to your loop. [code] #include <iostream> using namespace std; int main() { // The sum of no numbers is zero, so... float sum_of_positive = 0.0; float sum_of_negative = 0.0; for (float counter=-2.3; counter <= 3.0; counter+=.4) { … | |
Re: > PS: memcpy is safer No it's not. It will try to copy [B][I]n[/I][/B] characters whether it hits an architecture-dependent read boundary or not. Use [B]strncpy()[/B]. It is fully standard and stops in the right place. To convert a string to an integer [inlinecode]#include <cstdlib>[/inlinecode] and use the [B]atoi()[/B] function: … | |
Re: C++ doesn't really know the difference between an [B]int[/B] and a [B]char[/B]: both are just numbers but one is typically 8 bits wide and one is typically 32 bits wide. I/O routines know that the string of numbers you give it are meant to be printed as ASCII if it … | |
Re: I'm sure you are getting a perfectly fine return value. Your problem is that you have not supplied any type information that the compiler can use to "know" about your array. First, please see the Wikipedia [URL="http://en.wikipedia.org/wiki/C_syntax#Multidimensional_arrays"]here[/URL]. Next, please be aware that only the [I]first[/I] dimension can be [] in … | |
Re: I've not messed with MDI forms much, but when you create your mainform you have to modify some of the application's system window properties. [code] procedure FormCreate(...); begin exstyle := getWindowLong( application.hanle, GWL_EXSTYLE ) end; procedure FormShow(...); begin setWindowLong( application.handle, GWL_EXSTYLE, exstyle ) end; procedure FormHide(...); begin setWindowLong( application.handle, GWL_EXSTYLE, … | |
Re: How did you add it? (Did you use some component you got off the web or did you use the [B]Shell_NotifyIcon[/B] function?) Changing the icon is simply a matter of using [B]NIM_MODIFY[/B] with a different icon handle in the [B]hIcon[/B] field of the same [B]NOTIFYICONDATA[/B] record you first used to … | |
Re: Neither language can do this. "Bold" is a feature of your output device. What kind of output device are you using? Is it a console window? (If so, what OS?) Is it a Windows Rich Edit control? Is it something else? Let us know and we can give you some … | |
Re: Erm, the program is doing exactly what it is told to do. The error is that it is doing something you would prefer it not to do? Or that it is not doing something you would like it to do? Whenever you are getting a string from the user at … | |
Re: The [B]size[/B] variable is a [I]variable[/I]. The compiler does not know what value it might hold at any given time. Since you are using C++, you should be using a [B]vector[/B] or [B]deque[/B] for this instead of an array. But if you must use an array, just make one as … | |
Re: To calculate Fibonacci numbers you don't need a lookup table... Remember, each successive term is the sum of the previous two. Hence, you only need to remember two numbers at a time. Use a loop to find the nth term you want. [code] if n == 0 return 0 if … ![]() | |
Re: There's a blurb over on [URL="http://en.wikibooks.org/wiki/X86_Assembly/Protected_Mode#Entering_Protected_Mode"]WikiBooks[/URL] about entering protected mode. I've never done it (nor do I care to) so I know nothing about it. However, if you are not doing all of the things listed there your pc will decide that something is horribly wrong and reboot. Hope this … | |
Re: I hope that your struct was just missing the element part: [code] typedef struct [B]element[/B] { int data; struct element *next; } node; [/code] You aren't likely to compile properly if you use struct element without first tagging it... Hope this helps. | |
Re: Er, sure I have time for one more... Don't use [inlinecode]system("pause");[/inlinecode]. Tell your professor it is evil and non-portable and he shouldn't be teaching it. If he gives you a hard time tell him people who know better than he know better. (Yes, I know that sounds non-sequitur, but he … |
The End.