193 Posted Topics
Re: You should remove your scanf statements from the if {} and move them to under the while loop Something like this will keep looping until you have the correct number. Or you could restrict the user to a maximum number of guesses. [icode] while (loop==0){ printf("Guess> "); scanf("%d", &guess); if … | |
Re: You need to explain what problem you have with this code. Also it should be [code=cplusplus] | |
Re: Well you can go into your Windows Explorer, Folder Options, File Types set the default program to your program name for the types you want opened with your program. If you can open the file by using "Open With", this should work for you. | |
Re: A recursive palindrome is pretty simple, here is my attempt at the pseudo-code for it. [icode] function isPalindrome(char* str, int len): if len <= 1: return true; // we have a palindrome if len > 1; if str[0] == str[len] isPalindrome (str + 1, len - 1); else return false; … | |
Re: A global variable is a variable that you can access from every scope. That is, you would normally define it outside any function, and all of your functions would have access to it Local variables are defined it inside your function, and are passed as an argument to any other … | |
Re: You have to store the file name with location of the file. Otherwise there will be no way to access it later. So I'd suggest creating a string which has the location and the file name ie "C:\MyDir\MyFile". Also what you do mean by "it doesn't recognize it as a … | |
Re: Well most of these are linker errors, "undefined reference to function foo()" ... you need to locate where these functions are in the code and make sure that those files are being compiled and linked correctly. For example its missing the function _S_empty_rep_storage | |
Re: Why on earth are you deleting ptr in List::insert() [icode]delete ptr;[/icode] Once you delete it your ListPtr points to garbage, and essentially at the end of the insert you will have no valid elements in the list. You need to delete your list in the destructor. | |
Re: You could try using 2 pointers, where you increment the first pointer by 1 and the second pointer by 2. That way when the second pointer reaches the end of the list, the first one is at the middle. You can figure out whether its odd or even by making … | |
Re: cin attempts to read an integer from standard input. It waits until the user presses <Enter> and then attempts to convert the values entered and stores them into your variables. You can read multiple values at a time, by storing them in different variables. ie cin >> accountno >> amount … | |
Re: There is another problem with your code [icode] if(people[i].lastname == lastname) [/icode] You cannot compare two char arrays with the == operator. You either need to define them as "string" or you need to use strcmp() to compare them. | |
Re: In order to delete an element from a singly linked list, you need to save the previous pointer, and set a current pointer. You may do something like : [icode] if (current->data== max){ tmp = current; // is current the head, if so move the head. prev->next = current->next; current … | |
Re: You probably want to put a break after each case statement in your switch ? otherwise it will just go onto the next one [icode] switch (number){ case 1: break; case 2: break; ...... } [/icode] | |
Re: lol .. I am always amazed by such questions .. there is complex stuff and then there are just idiotic unreasonable expectations and this falls in the latter category. how on earth do you expect to generate n numbers without using a loop ? Now you could write n assignment … | |
Re: First add code tags, and explain what your problem is. Also this looks like a C program, so you probably want to post it in the C forum. | |
Re: As far as I know, the compiler should just ignore the comments while parsing your code. So it should not have any effect on executable size or speed. | |
Re: unsigned int value would be your decimal value. The [icode] static const char *binary[/icode] is a list of binary values that are being converted to their decimal equivalent. In your case you are getting this input from the user, so you don't need it. Also since a user could enter … | |
Re: Again, add your code tags, explain your problem and this is a C program not a C++ program, so post it under the correct forum. | |
Re: Well in your function declaration [icode] float computeNet (money); [/icode] money is not a recognized datattype. Its probably your variable name. You probably want [icode] float computeNet (float money); [/icode] | |
Re: Does your code compile ? One thing I notice is that [icode] bool space=true;[/icode] .. bool is a C++ data type. | |
Re: I am going to try to answer this, but I don't completely understand your problem. Your function s_display() will process the stack routine and then return back to the switch statement in your main(). If you want to continue asking the user to process a different data structure type after … | |
Re: A fairly simple explanation of how you can use the sieve of eratosthenes [URL="http://en.wikipedia.org/wiki/Sieve_of_Eratosthenes"]here[/URL] | |
Re: Use a structure [icode] struct familyRecord{ char* name; char* birthDate; int isMarried; int nChildren; . . . }; [/icode] | |
Re: I am really not sure why you have your class files in packetstructure.cpp. The declarations should be in a file called packetstructure.h As said before, you need to include packetstructure.h in fifoqueue.h, and then include fifoqueue.h in main.cpp and fifoqueue.cpp. The cpp files only need to reference your definitions, so … | |
Re: That is how you include the header file. You will also need to include <iostream> in your Pen.h files since there are some print statements cout in there. So you may want to move that to the Pen.h header file. | |
Re: You cannot use the overloaded operator = to directly assign a vector to an integer array. The = operator is overloaded to allow you to assign one vector to another vector. This is the protoype : vector operator=(const vector& c2); In your case you will probably need to loop through … | |
Re: A tutorial that may help [URL="http://mrbook.org/tutorials/make/"]here[/URL] I would suggest downloading the Makefile copy and then making your changes to the existing Makefile. That is always the easiest way to make sure you do not mess up on the tabs ! | |
Re: I think what you are trying to do is insert values in a doubly linked list in alphabetical order by the last name ? if so, you aren't going about it correctly .. lets assume you have a set of 5 elements you want to insert in the list; We'll … | |
Re: What you are doing will work i.e. RF_RXTXPAIR_SETTINGS code RF_SETTINGS[2]; If you want to dynamically assign an array size at runtime, you could do RF_SETTINGS = malloc (number_of_elements * sizeof(RF_RXTXPAIR_SETTINGS)); | |
Re: That shouldn't matter. As long as your declare your your strings using the type "string", you will be able to store a string of any length for your string values. This is completely independent from your declaration of a Contestant object. | |
Re: I ran your code and it works fine. I would suggest a couple of things. "list" is a reserved STL container so you may want to call your variable something else. And your loop should be [icode]for (int i = 0; i < list.size(); i++)[/icode] ie < not <= . … | |
Re: What does the sample data in your file look like ? Regarding your code, you need to be careful about the loop which is reading from your file. Unless your total number of records in the file is a multiple of 9 you will not read the values into the … | |
Re: So that you can obtain a certain level of protection. For example, You have an input data file with sensitive information and you don't want anyone to modify it. You can write a function that accesses and reads from the file using an ifstream file pointer, but if the caller … | |
Re: Yeah it should be "t:" and if t is an optional argument it should be "t::" why don't you like getopt ? | |
Re: I agree.. this is painful .. To add to what Sci@phy told you, take a closer look at this [icode] float calculate_mile_per_hour(float miles, float minutes); { float mile_per_hour; miles_per_hour = (miles * 60)/minutes); return (mile per hour); } [/icode] First of course, remove the semi-colon from all of your function … | |
Re: You could try using valgrind on Linux to see if you have any memory errors. See [URL="http://valgrind.org/"]http://valgrind.org/[/URL]. | |
Re: Its already 3 hours past .. but here are a couple of things I see Your screen.h file has [icode]#ifndef SCREEN_H #define SCREEN_H #include "Screen.cc"[/icode] And your screen.c file has [icode] #ifndef SCREEN_H #define SCREEN_H #include "Screen.h" [/icode] .. not a good idea imo. I would suggest removing the "#include … | |
Re: main() is the point of entry to your program .. so there is no way around it. I am not even sure why you want to do this ? | |
As long as we are on multithreading, I have a question too .. I basically have a implementation of pthreads on Linux and I want to port it to Windows .. I have read a bunch of docs on how to do this, but I also came across the pthreads-win32 … | |
Re: Are you looking to understand how the variable argument list works ? If so read [URL="http://bobobobo.wordpress.com/2008/01/28/how-to-use-variable-argument-lists-va_list/"]this[/URL] ... | |
Re: You need to give us more information. Can you post the link errors that you get ? Make sure that you have the correct prototypes in the .h files and that you are including the correct .h files in main and your .c files. | |
Re: I don't know about C++, but in C you can use the function fcvt .. which I think is faster than sprintf . See [URL="http://www.mkssoftware.com/docs/man3/fcvt.3.asp"]here[/URL] | |
Re: I will try to answer these .. but I'd suggest looking them up online also. 1. #pragma is a compiler directive. For example #pragma pack(n) .. specifies the packing alignment for structures and unions (ie 1 byte boundary, 4 byte boundary and so forth). [URL="http://dn.codegear.com/bg/article/21943"]here[/URL] is some more information. 2. … | |
Re: Lets assume you have Stack1 (push_back, pop_back) and Stack2 (push_front, pop_front) Say you want to enqueue 1,2,3 Lets enqueue the numbers onto Stack1 using push_back Stack1 looks like : back |3|2|1| front Stack2 looks like: back |EMPTY| front Now you want to dequeue a number. So lets pop_back all the … | |
Re: As you can see from your messages, your code is segfaulting inside one of the std::string operator = overload functions, which in turn calls strlen. A segfault is usually an access violation, ie you are writing to or reading from memory that is beyond what has been allocated to you. … | |
Re: Please use code tags to make your code easier to read. Your function prototype .. int delfn(acmetype *&head) .. doesn't make any sense. You probably need something like .. I am surprised your code compiles :?: [icode] int delfn(acmetype *head) [/icode] In your statement "if( nnptr->link == NULL )" .. … | |
Re: What about using fread() to read a large buffer and then write it out ? | |
Re: Well looks like you have the function getframe0() defined twice in the files getframe1.c and getframe0.c And you don't have the function getframe1() defined anywhere. I think what you want to do is rename getframe0() to getframe1() in getframe1.c ? | |
Re: check out this thread [URL="http://www.daniweb.com/forums/thread147354.html"]here[/URL] ... and see if you can find what you need. | |
Re: gcc allows the // comments. The only compiler I have come across which doesn't allow // on C code is the AIX C compiler. |
The End.