556 Posted Topics
Re: You can only store a single character because in your node structure [code] struct node { char nbook; struct node *next; }; [/code] You only provide space to store a single character. You need an array of characters if you want to store a whole string. | |
Re: You would perhaps do better to specifically catch the values 2 and 3 and return TRUE before the line in green. The line in green could then check if the number is divisible by 2 and return FALSE if it is. Numbers divisible by 3 are caught by your loop … | |
Re: You are not altering the size in remove. Resize still refers to m_size At line 95 you have [icode]index—[/icode] but I think you mean [icode]index--[/icode] NOTE that is not a minus in what is currently in your source file. | |
Re: dptr and bptr_1 both point to the same allocated objected. You should only delete an object once, as soon as you delete it the pointer becaomes invalid and any access to that pointer, either dereferencing it or trying to delete it again is undefined behavior. You allocate the object pointed … | |
Re: Your problem is in your array class, you have declared half you data members at the top of the class (line 9) and then some more half way down (line 42) and as a result you have 2 size members which you use interchangeably but you only initialize one of … | |
Re: It rather depends on what else is implement and how you have implemented your division. For example if you have implemented the division as while number is greater than divisor subtract divisor from number then whatever is left when you finish is the remainder. If you want a specific operator … | |
Re: Compare line 33 and 36, you call printukas with no parameters but it expects 1. This is why you should provide prototypes for your functions before calling them. I expect you were getting and ignoring compiler warnings. Don't ignore compiler warnings they have been printed for a reason work out … | |
Re: In this case these line are declaring variables the * means pointer to so in int* a; This is read as a is a pointer to an int, that is a contains the memory location of an int variable. int** b; There are 2 * you read the pointer to … | |
Re: When you say it fails I assume you mean gives the wrong result? This line of code is the issue partial = a->word0 + b->word0; word0 in your structure is 16 bits and you are on a 16 bit platform/compiler so this will perform the calculation in 16 bits and … | |
Re: That is correct but I believe you have misunderstood what the || operator does. || is the logical or operator, it's output is true or false, or in integer terms 1 or 0. The inputs are treated as logical inputs which means in C++ 0 = false anything else is … | |
Re: You for loop condition is wrong [icode]i<=-lenght[/icode] the - sign means that for a string with at least 1 character the loop never runs because 0 is greater than all negative numbers. Also remember that C++ indexes start at 0 so if an array has 4 entries its valid indexes … | |
Re: You are missing an opening brace in your declaration of accounts [code] int accounts[SIZE] = [b]{[/b] 5658845, 4520125, 7895122, 8777541, 8451277, 1302850, 8080152, 4562555, 5552012, 5050552, 7825877, 1250255, 1005231, 6545231, 3852085, 7576651, 7881200, 4581002 }; [/code] | |
Re: The problem is the way you have written your outer for loop, even though you don't increment i when out output a factor the loop always increments i so you never test the same factor twice. However if you remove the i++ from the loop you will have another problem, … | |
Re: The problem is that you only have 1 buffer [icode]word[/icode] so as soon as you encrypt the string it contains you no longer have access to the original data. What you need to do is have 2 buffers and then copy the input data to the second one and do … | |
Re: That just ain't how you do it, you need to implement (overload) ArrayOfTypes::operator[] and MyType::operator= separately to achieve what you want not try and do it together which is presumably this [code] ArrayOfTypes array; MyType value; array[10] = value; [/code] ArrayOfTypes::operator[] returns a reference to a location in the array … | |
Re: You could implement this fairly easily with a std::map rather than writing all your own code. However clearly in your valueAt method you need to be iterating over the entire array not just performing a single if test. Your MatrixType must surely store a std::vector (or array) of oneitem and … | |
Re: You really should have posted the errors at each step, then you could have tried to help with the original problem rather than the problems with the non-working solutions to the original problem. For starters [icode]"www.facebook.com".c_str()[/icode] the problem here is that "www.facebook.com" is not a string object so you can … | |
Re: Use 2 64 bit numbers in a class. What do you want to generate the key from? | |
Re: You need to explain more fully. It sounds like this is really a C question, you appear to be calling a C API even if your program is written in C++. Are you saying that you are trying to write you own method called shutdown but you still want to … | |
Re: The function pointer in the structure is a data member of the structure just like any other data member and can be initialized like so [code] struct foo bar = { func }; [/code] But you are always either going to have to explicitly initialize it or assign it. | |
Re: The real answer is that the overhead of calling a virtual function is so low that it is unlikely to cause you a problem in the majority of cases. This is definitely a case of trying to solve a problem before you know it exists. In all likely hood your … | |
Re: Sure that shouldn't be typeinfo.lib? | |
Re: getchar returns int not char. You need to store the value as an int to test against EOF because EOF is defined as an int (normally with the value of -1). If you converted the value of getchar to a char before comparing to EOF you would have trouble in … | |
Re: You can't do it will a structure alone, you will need some code too. | |
Re: You can use Visual Studio its OK. But if you are using Linux and Windows you may want to try something like Code:Blocks or Eclipse which are multi-platform and run on both Linux and Windows, that way you only have to learn the ins and outs of 1 IDE that … | |
Re: It would help if you posted your code in CODE tags. As well has having functions called smallest and largest you also have variables (int) called smallest and largest. | |
Re: The only place I have come across far pointers in far pointers is as an extension in WIN16 C compilers. 16 bit Windows (WIN16, Windows 3.11 and earlier) had 16 bit addressing, which allowed you to access all of your 64kbyte memory segment, the pointer was the offset in the … | |
Re: It would help if you posted the entire error message because following the text "unresolved external" is usually the name of the symbol it is unable to find. | |
Re: [icode]char* temp = (char*) malloc(sizeof(*string1));[/icode] Consider string1, what type is it? char * from the function prototype. In that case what type is *string1? If string1 is char * then dereferencing it gives char. What does sizeof(char) return? 1 (by definition in the C standard) I do not believe you … | |
Re: You can't initialise anything that has already been declared. You can only initialise something at the time it is created, after that it becomes assignment. And to answer the spirit of your question no there is no way to assign to all members of an existing array without recourse to … | |
Re: Perfect numbers are few and far between the next perfect number after 8128 is 33550336 which is rather greater than 1000000 so your program can not find it. It would appear that your program may be working. | |
Re: You are not taking account of escaped characters in strings, for example how would your code cope with the string [icode]"\"//"[/icode]. You are not taking account of character constants, how would you software cope with [icode]'"'[/icode] This [icode]while ( (ch=fgetc(fd)) != (feof(fd)) )[/icode] is wrong and might well result in … | |
Re: That is not a part of the program itself as the program is not running until <Enter> has been pushed on a valid command line. It is a function of the shell (Bash) what I can not tell you is if it is built into the shell or if the … | |
Re: Start a command prompt and run you program in it. Dev-C++ is a bit long in the tooth you may want to try something a little more up-to-date like CodeBlocks. | |
Re: An array of structures with what members? If you do not know the format of the binary file about the best you can do is read it into an array of char. | |
Re: The error probably appears random because you are calling gai_strerror when you should be calling strerror. | |
Re: At line 100 this [icode]letters[ ((i % 100)/10)* 10 ] + letters[ i%10 ][/icode] can be replaced with [icode]letters[ i % 100 ] [/icode] Think about say 345, this is working out the number of letters in 45, you method adds the number of letter in 40 (forty) and 5 … | |
Re: Of course like this [code] #define ROOT "C:\\SomeRoot\\" #define SUB_DIR ROOT "SubDir\\" [/code] A rarely use feature of C++ (and C) is the the compiler automatically contatinates contiguous strings. A better question is should you given this is C++ or should you just use constant objects [code] const std::string root … | |
Re: I would say you have 2 options (remembering that the majority of processes, even multi-threaded ones do not actually run concurrently, mostly they time-slice, that is each thread gets a chance to run in turn and while a thread is running non- of the other threads of the process are … | |
Re: Your code doesn't try to send anything. Most UARTs also produce an interrupt, normally on data received, on error and possibly on ready to send data. It is common (and therefore I assume I good approach) to handle data receive using the UARTs interrupt and it is often a requirement … | |
Re: You have some many blank lines it makes your code much longer than required and so less readable. You have redundant duplicate variables, for example M in dc4 is just a copy of nrows, however neither variable is ever changed so one of them is redundant. However I believe your … | |
Re: The if statement (line 32 - 48) needs to be inside the else block (line 27 - 31) because that code should only be run if ab != 0. The return at line 24 then becomes redundant (it is not uncommon for coding standards to ban returns in the middle … | |
Re: Global data is bad, however it is not always avoidable. There are no hard and fast rules in C++ just best practice and less good practice and you need to know when to ignore best practice. I would say make a big effort to avoid making any global variables that … | |
Re: You do not have to wait to see if an event is set. You can test the event without waiting if you call something like WaitForSingleObject with the dwMilliseconds parameter set to 0 then the function will return immediately indicating if the event signalled or not at that time. | |
Re: Or a set would work, a set of the actual values would returned not found if you looked up a non-existing value. On NULL it really only applies to pointers. It is a special representation for the platform that indicates that the pointer is invalid. The NULL pointer for a … | |
Re: Line 28 and 47 of the client you strcat into an allocated buffer that contains random data (malloc does not clear the contents of the memory it allocates). Make the first call in each of those sets strcpy. | |
Re: And what does that program do when the bot handle respectively 1.It has to follow white line track on the black background. 2.It should has high speed. 3. The path has intersection, curve turns, sharp turns (60 degree turn), discontinuities. Does it handle them correctly or does it do something … | |
Re: Talking of IDEs recently I have been using Geany, which is less of an IDE and more of an extended editor. However the reason I mention it is that (assuming you already have the compiler installed but I am using it on Linux so that is less of a problem … | |
Re: Do you mean you have strings of 1s and 0s that you need to add as if they were binary numbers? All actual integers are held in binary (on the whole) anyway so adding 2 binary digits is as simple as [code] int a = 2; // binary 10 int … | |
Re: Lin 6 fills me with some dread. What do you suppose [icode](end-begin)[/icode] does? When end and begin where pointers in your array/pointer implementation the answer was obvious but now end and begin are not pointers, they are objects and I am slightly surprised that that construction even compiles as I … |
The End.