3,183 Posted Topics
Re: This: strncpy(p->name[(p->count)++], q, 20); Is roughly equivalent to this: strncpy(p->name[p->count], q, 20); ++p->count; I'm not sure where your confusion lies, but I'm all but certain you're overcomplicating things. | |
Re: > I know the header files are never compiled. Header files are always compiled if you include them. The problem is that you have an object definition in a header file, which means that by including it more than once you've violated the one definition rule. Inside the header you … | |
Re: Your call to mysql_query() failed and returned FALSE. Use [mysql_error()](http://php.net/manual/en/function.mysql-error.php) to get details as to why the query failed. | |
Re: `toMakeFood` doesn't exist because everywhere you have a declaration of it, you're saying "defined elsewhere" due to the `extern` keyword. Add an includes.c file with this: bool toMakeFood = false; And don't forget to link that file in with the rest. The header will provide multiple delcarations while the .c … | |
Re: The compiler is right. You declare copies without initializing it, then immediately try to print its value. That's undefined behavior, and constitutes a bug. | |
Re: I'd mention that the code works on my end and ask how they're testing it on their side. Make it clear that you respect their decision to halt the interview process and that you're most interested in learning what you may have done wrong. | |
Re: > *t=*t; This accomplishes a whole lot of nothing. All you're doing is simulating the effect of strlen() without the overhead of a function call, so no assignments are necessary. Just bump the value of `t` until it's pointing to a null character: while (*t) ++t; You also don't use … | |
Re: Such a list would be subjective no matter how you look at it because everyone has different goals and problems that need solving. A better approach is to consider each problem you have when you have it and then ask if there's a function out there that already does it. … ![]() | |
Re: You're focusing too much on the little things and not seeing the big picture. The problem is very simple: display any line where the first non-whitespace character is a digit. To do that you read each line in turn, find the first non-whitespace character, and print it if it's a … | |
Re: > I don't know of any IDE's that exist on them. There are IDEs, editors, and compilers that run on a tablet...but they all suck. However, it doesn't strike me as unreasonable to use something like Ideone to write and compile code, then copy/paste it into a post all on … | |
Re: There aren't equivalent headers unless you're using a compatibility layer. A better approach would be to port your code based on features, and look for equivalent features in the Windows APIs. | |
Re: > having trouble finding this anywhere, on a 32bit computer, how many bytes does it take to store ; long int, unsigned char,float, double You're having trouble finding it because there's no absolute answer. Only char has a guaranteed size (it's always going to be 1), the rest are implementation … | |
Re: > I dont use memcpy often As well you shouldn't. memcpy() is a very low level function that was inherited from C. The problem with memcpy() in C++ is that it doesn't respect class structure or construction/destruction, so unless you have what is called a [POD](http://en.wikipedia.org/wiki/Plain_old_data_structure) type, use of memcpy() … | |
Re: > Modify the Downdog Yoga Studio program This suggests that you have pseudocode from a previous exercise and the current exercise is an extension of it. | |
Re: > i would like to enter 6 random objects on this grid that the arrow can pick up where would i enter the random number generator to put them on the grid? I'd put them in SetupScreen(). Once you're done filling the grid with dots, randomly generate six different coordinates … | |
Re: > To do this, you have to use Win32 (Windows API). Um...to determine the OS you need to use the Windows API? Doesn't that presume that the OS is Windows and then you're just drilling down to the exact version? ;) | |
Re: > `number *p;'` > `p->count=0;` This is a classic error with pointers. A pointer **MUST** point to a valid object that you own. If the pointer is uninitialized, as in the two lines above, you **CANNOT** dereference it...period, full stop, no exceptions. Once you initialize the pointer, all will be … | |
Re: `p_array` is a pointer. When you use the subscript operator, that pointer is dereferenced. In other words `p_array[index]` is functionally identical to `*(p_array + index)`. Now, when you dereference p_array, the result is also a pointer, specifically a pointer to char. So this line is correct because the %s specifier … | |
Re: Are you creating the exam or taking it? | |
Re: You need to break the line up such that the ID can be compared. If subsequent details also need to be treated separately then strcmp() and strtok() come to mind as a viable first attempt: #include <stdio.h> #include <string.h> #define WHITESPACE " \t\n\r\f\v" int main(void) { FILE *in = fopen("test.txt", … | |
Re: > How to call a C++ function which is compiled with C++ compiler in C code? The function must either be compiled with C compatibility in place or wrapped in such a function, otherwise C won't be able to recognize it due to C++'s name mangling conventions: extern "C" { … | |
Re: > I get an error message about MDAC 2.6 or greater needs to be installed. Have you tried installing MDAC 2.6 or later? While I wouldn't recommend Access as your database, simply because it's not scalable and I've had bad experiences upgrading people who started with Access to a *real* … | |
Re: > Can someone explain why this would be a good idea? It's a little more natural syntax for setters and getters. > It seems like a lot of work for little benifit. Indeed. I personally wouldn't use it unless the problem domain suggests a distinct benefit, but I also have … | |
Re: > Oh and by the way, is it okay to post in purple? Like i just did now? It's okay, but you're technically not posting "in purple". You're posting with heading tags, which may change their look and feel to be something other than purple. If that ever happens, full … | |
Re: > My question is HOW?? When I closed the file then how it can be in use of some other process?? My gut reaction is to say that this is a timing issue, but it's possible that fclose() failed. First try testing the return value to see if there were … | |
Re: Top down means starting at the highest reasonable level and then digging into details. It's an overall structure based approach rather than bottom up, which is more of a progressively evolving functionality approach (starting with the details and working up). | |
Re: Somehow I get the impression that he wants numeric values rather than strings. In that case it would be necessary to either convert the string to a number or build the number directly. For example: #include <algorithm> #include <cctype> #include <iostream> #include <string> int digit_value(char ch) { const std::string digits … | |
Re: > Debugger shows this as 1515804759 in Decimal. that is when 5958595a taken as a whole. > why doesn't it show 87888990 like when they are take separately? Because eax is being interpreted as an integer value instead of an array, so all four bytes are a single entity totaling … | |
Re: Then I suggest you search google for some existing programs or write your own. | |
Re: > If I want some software which can be compiled as part of my application / project etc, something which has little or no reliance on external programs (all packed in as part of my program) then what is that called. I'd call it standalone software, assuming you mean a … | |
Re: > 1.If cin and cout objects are in the 'iostream' , why do we need to declare it again using 'std' ? <iostream> is the header that contains declarations. Without those declarations your compiler doesn't know that the names you use exist. The names themselves are declared within a namespace … | |
Re: You can have an identity column with autoincrement properties that isn't the primary key. In the new table, just create the new column, set it to identity "Yes", and with increment step and seed of 1. | |
Re: What you're asking for is a [random shuffle](http://en.wikipedia.org/wiki/Fisher–Yates_shuffle). | |
Re: I'm having trouble deciphering that incomprehensible mess. Could you please rephrase your question? | |
Re: Note that this is a dual feature, and the second part makes the first part less useful. If we implement some sort of notification that people are online, we'll also need to include a way to disable it and allow people to be invisible. Otherwise it has too much of … | |
Re: So...have you looked into the documentation for the [ProgressBar](http://msdn.microsoft.com/en-us/library/system.windows.forms.progressbar.aspx) control? | |
Re: > but then i thought what if the user inputs a 2 digit number or a 3 digit number? You'd need to extract tokens rather than characters. For example: #include <ctype.h> #include <stdio.h> #include <string.h> typedef enum token { UNKNOWN, VALUE, OPERATOR, VARIABLE } token_t; token_t next_token(char buf[], size_t size) … | |
Re: > You could declare a char[BUFSIZ]. It is a max length your system can use. Um...no. BUFSIZ is a macro representing the size of the default buffer used by the stdio library. It's nearly always a great deal less than the maximum length string you could define. BUFSIZ also doesn't … | |
Re: You've cut and pasted parts of the code but neglected to modify everything. For example, in the file_w part of the code you're still working with fileread rather than filewrite. Compare and contrast with this corrected code: #include <stdio.h> #include <string.h> #include <stdlib.h> int main(void) { FILE *file_r, *file_w; int … | |
Re: What do you mean by "twinkling" motion? | |
Re: The comparison delegate returns an integer denoting the relation between the two objects: 0 for equal, -1 if x is "smaller", and +1 if x is "larger". So it would be more like this: Private Function SortMyList(ByVal x As MyType, ByVal y As MyType) As Integer Dim tsX As TimeSpan … | |
Re: So it looks like you're not actually doing a full merge sort, you're just merging together three arrays that are already sorted. Really the only tricky part of this is taking what you know about merging two arrays and extending it into three. Here's a two way merge: int dst[size … | |
Re: A static member is shared between all objects of the class whereas each object of the class contains a copy of the instance member. It's really as simple as that, though the `static` keyword is heavily used for different purposes in C++. [LearnCpp - Static Members](http://www.learncpp.com/cpp-tutorial/811-static-member-variables/) [IBM Reference - Static … | |
Re: If `char` could represent the same thing as `wchar_t` then there wouldn't be two different types of characters. You have a wide string, and thus you need to either convert it to a narrow string *iff* you're sure that the narrow string can represent it, or properly display the wide … | |
Re: Pseudocode is just a formalized list of steps, there really aren't any rules beyond generally trying to remain consistent and logically sound. So *your* job is to break the assignment into component parts. What steps are involved? What order are the steps in? For example, it's not unreasonable to have … | |
Re: Is this a question about the DateTimePicker or about MySQL? If it's the former then the control has a Value property that gives you the stored DateTime object. You can then get the long format as a string and save it to MySQL: Dim longdate As String = dateTimePicker1.Value.ToLongDateString() ' … | |
Re: Here's pseudocode for what you're doing: cx = 10 while cx <> 0 while cx <> 0 int 21h dec cx loop dec cx loop So cx starts out as 10 and gets decremented to 0 by the inner loop. Then the outer loop decrements it again to make it … | |
Re: > after getchar i use another getchar to clear the buffer Though there's no guarantee that the second character is a newline, so you're making an unwarranted assumption about the user's behavior. | |
Re: You're aware that this is the very first program anyone learning assembly will have to write, and it's **ALWAYS** provided in toto by the teaching resource (ie. book, website, or course notes), right? So either you're lazy to the point that shocks even me, or you need to ask a … | |
Re: > argv[0] is always the program name. Not always. *If* argc is greater than zero, argv[0] is allowed to be an empty string, should the program name not be available for some reason. Even if argv[0] isn't an empty string, the format of the "program name" is implementation dependent. It's … |
The End.