6,741 Posted Topics
Re: While fgets() suggests reading from a file, you [I]can[/I] pass stdin as the stream for user input. | |
Re: Can you be more specific? "Leaving the first three characters" is ambiguous. Do you want to print only the first three characters of a string, or all characters [i]except[/i] the first three? | |
Re: [QUOTE]A function name basically evaluates to a pointer. However, don't quote me on that.[/QUOTE] That's a reasonably accurate statement. You can only do two things with a function: call it and take its address. If you're not calling it, then you're taking its address, and the result is a pointer … | |
Re: [QUOTE]The problem is that I don't know how many integers in the string would be otherwise I would have used sscanf with a format specifier.[/QUOTE] strtok() would be the easiest option, but you also need to keep in mind having sufficient memory to hold the integers. If the amount is … | |
Re: [QUOTE]I am looking for a website that I can download Microsoft Visual c++ 6.0 or whatever it's called, the compiler.[/QUOTE] The compiler itself is called CL.exe, but since there are so many dependent files it's best to install the IDE package. [QUOTE]Please give me a good up to date link … | |
Re: [QUOTE]I may have written it a bit 'cryptic' as to maybe minimize random ripoffs.[/QUOTE] Let's start with this. You're not going to make money off of this algorithm, and the bragging rights are tangential to devising a solid algorithm. I wouldn't worry about anyone ripping off your idea, but being … | |
Re: Threads merged. | |
Re: It's possible to "catch" a segmentation fault with a signal handler, but you can't resume the program after the handler runs, so it's not very useful other than terminating gracefully. In your case the better option is to fix the bug that caused the fault in the first place. :icon_rolleyes: | |
Re: [QUOTE]How do you block the user to only enter a number for example 1 to 6?[/QUOTE] You write your own raw input handler to read keystrokes and interpret them as desired. It should go without saying that this is terribly confusing unless you own the canvas[1] or are taking input … | |
Re: [QUOTE][CODE]fscanf(fp, "%d", &temp); if(temp!='\n')[/CODE][/QUOTE] This is an impossible case unless one of the numbers happens to match the numeric value of '\n', and if that happens you'll get unpredictable behavior. You told scanf() to read integers, and it will discard all whitespace in the process. What you need to do … | |
Re: [QUOTE]I know how to create a program that sorts names and numbers that are entered from a keyboard, but don't know how to do it whit a file.[/QUOTE] Read the file into memory, then sort it as you normally would. While it's possible to sort the file without loading it … | |
Re: 1) <iostream.h> is an old style header that's no longer supported by modern compilers. Your compiler is correct in forcing you to use the standard <iostream> header, which also wraps everything in the std namespace. 2) Your question is nonsensical. Please provide an example of using pointers that's improved with … | |
Re: Please post your code and the errors you're getting. Just because the errors are being thrown in compiler-provided headers doesn't mean [I]your[/I] code isn't wrong. | |
Re: [QUOTE]Would the last line work?[/QUOTE] No. [QUOTE]Or would I have to declare a function to execute that last line?[/QUOTE] Yes. However, note that you [i]can[/i] initialize sasd to that expression in the global scope: [code] int vap = 7; int pav = 2; int sasd = vap * pav; [/code] | |
Re: The good news is that if you're using a hardware scanner, the hard part is already done: the scanner will recognize and translate the contents of the barcode into a string. The bad news is that barcodes don't typically contain the price of an item, they use an [URL="http://en.wikipedia.org/wiki/Universal_Product_Code"]UPC[/URL]/[URL="http://en.wikipedia.org/wiki/Electronic_Product_Code"]EPC[/URL] encoding … | |
Re: [QUOTE]It would appear that the memory space on which the string is stored is not modifiable.[/QUOTE] Correct. String literals are defined as read-only by the language, and strtok() modifies its argument. | |
Re: [QUOTE]1. What is your definition of management?[/QUOTE] The task of keeping team members focused and sufficiently insulated from external concerns to facilitate the doing of their jobs. [QUOTE]2. Do you utilize the four functions of management( planning, organizing, leading, and controlling) and which do you feel is most important?[/QUOTE] While … | |
Re: Your prefix() function signature is jacked up. Fix that and you'll get other errors that are easier to fix. | |
Re: [QUOTE]I have an idea with this program. I get an input, store it in s1. strlen to check how long s1 is and then that would let me know if its in the hundreds,tens, or ones.[/QUOTE] That's a good approach. If you know what the digit is and what place … | |
Re: [QUOTE]Can any body help me for solving the code using C language.[/QUOTE] Start by ignoring the requirement to handle the "::" shorthand. That's the only part of the problem that makes it even remotely difficult. [QUOTE]You will likely want to break the problem down into two distinct parts: parsing input … | |
Re: Start by checking if an array is sorted. Or in your teacher's terms "single sorted". :icon_rolleyes: Once you have the logic for determining if a sequence of values is in sorted order or not, you can apply a filter such that only even numbers are considered or only odd numbers … | |
Re: You may quote and reference Daniweb content, but you may not reproduce the content. The difference is that a quote is a relatively small part of an article written in your own words, and reproduction is a large scale copy/paste of our content with little or none of your own. | |
Re: While none of your design ideas are unreasonable, I'm still not sure I understand the point of this application. Is it a bulk installer for system admins? | |
Re: Is that the exact question you have, or are you paraphrasing it into incoherence? | |
Re: Because it's a 16-bit compiler designed for MS-DOS in the 80s? Grow up and use a modern compiler, or stop whining and downgrade your OS to something closer to the Turbo C era. p.s. For those of you who are tempted to chime in that Turbo C can be run … | |
Re: For each number you read, loop over all of the numbers presently read into the array and compare with the number. If there's not a match, append the number to the array. Repeat until the array contains ten numbers. | |
Re: [QUOTE]try subtracting 42 or 48 from the character, I think one of these is the right number.[/QUOTE] It's 48 in ASCII and Unicode. But you don't have to remember what the value is if you simply subtract the character '0': [code] for (char x = '0'; x <= '9'; x++) … | |
Re: Can you post more code? Specifically, how are DEMOD_NBR_INPUTS and iter defined? Here's an idea: write a complete program that's both small and exhibits the error. Then post that so other people don't have to play twenty questions with you just to get the necessary information for helping out. | |
Re: It depends on how you're storing the items of the stack. Personally, I would use an array of structures: [code] struct item { char a[ITEM_SIZE]; }; struct item stack[STACK_SIZE]; size_t top = 0; [/code] With that setup, pushing and popping are a simple matter of copying the contained array: [code] … | |
Re: A file descriptor is conceptually much like the FILE pointer you use in standard C. In fact, on systems that use file descriptors (such as Linux and Unix) you'll find that the definition of the FILE struct actually stores one as a the underlying file handle. On the assumption that … | |
Re: [QUOTE]I must have the char b declared is it?[/QUOTE] Yes, there must be an array (or simulated array) with enough space allocated to pass to sprintf(). [QUOTE]So in my case I should put something big right?[/QUOTE] Let's do the math. Following are the fields you said you want to serialize … | |
Re: [QUOTE]btw, {ICODE} for Toolbar on quick reply, would help an IT forum member(hopefully not just me).[/QUOTE] Unfortunately, we tried it and there were [i]far[/i] too many instances of icode tags where code tags were needed. If you need the extra controls, jumping to the advanced editor from the quick reply … | |
Re: [QUOTE]It's simply leads to more memory consumption....[/QUOTE] Properties don't consume memory in the object, they're a form of method that acts like a field. [QUOTE]Somebody says that,it provides security,but here still anyone can edit the value of PI. Then how we can say it as a secured one....[/QUOTE] If you … | |
Re: [QUOTE]but I'm not an analytic person nor good in designing..[/QUOTE] Experience and effort often trumps natural talent. As long as you enjoy what you do, lack of talent shouldn't stop you from trying. | |
Re: Please post more code. Ideally it would be a complete ([I][B][U]SHORT![/U][/B][/I]) program that we can cut, paste, and compile as-is and see the error. | |
Re: [QUOTE]I tried to fix the bold and declared it, but when I declare it, other errors show up. I don't get it. How do I fix this?[/QUOTE] What errors are you getting? :icon_rolleyes: [QUOTE=firstPerson;1702892]>>[icode] omp_get_max_threads ( ) [/icode] Spacing issue I think. Try [icode] omp_get_max_threads( )[/icode][/QUOTE] Whitespace is largely insignificant … | |
Re: [QUOTE][CODE]ss=time[7]+10*time[6]; mm=time[3]+10*time[4]; hh=time[1]+10*time[0];[/CODE][/QUOTE] This won't work because the digits are characters. You need to subtract '0' from them to get the numeric representation: [code] ss=10*(time[6]-'0')+(time[7]-'0'); mm=10*(time[3]-'0')+(time[4]-'0'); hh=10*(time[0]-'0')+(time[1]-'0'); [/code] Note that I also fixed the equations to do what you intended. [QUOTE][CODE]time=hh+mm/60+ss/3600;[/CODE][/QUOTE] This is completely nonsensical because you're trying to assign … | |
Re: [QUOTE]I searched all over the net trying to find the reason behind why numbers are illegal as first characters in naming identifiers in C++, they say its illegal but they don't say why its illegal[/QUOTE] Leading digits would be confused with numeric literals. If you allow leading digits then that … | |
Re: Your use of strtok() is correct. The problem is your use of the uninitialized argv. You need to make sure that all destination strings have been allocated sufficient memory. Compare and contrast: [code] #include <stdio.h> #include <stdlib.h> #include <string.h> char *copy_str(const char *s) { char *copy = malloc(strlen(s) + 1); … | |
Re: Do you need to retain the original order? The standard library has a set_intersection() function that does what you want, but both sets need to be sorted: [code] #include <algorithm> #include <iostream> #include <iterator> using namespace std; template <typename T, int N> int size(T(&)[N]) { return N; } int main() … | |
Re: Hmm, I'd say that a good solution is to rewrite your reverseString() entirely so that it builds the reversed string rather than tries to fill a caller provided object: [code] #include <iostream> #include <string> using namespace std; string reverseString(string::const_iterator first, string::const_iterator last) { if (first == last) return string(); return … | |
Re: [QUOTE]Well, seeing as no one seems to be taking my deadline as seriously as I[/QUOTE] I would think that's obvious. Your deadline means nothing to us, and many of us are perverse enough to respond more slowly to "urgent" questions. Let's also not fail to notice that it's unreasonable to … | |
Re: [QUOTE]If someone could help me with the most efficient way, I would greatly appreciate it.[/QUOTE] Your code is I/O bound, "efficient" shouldn't enter your vocabulary unless user testing shows perceived performance to be unacceptable. Though since you asked, I would prefer accepting a series of base/height pairs on the same … | |
Re: Look closely at these two loops and find the difference (aside from int vs string): [code] while (person[L].number < pivot){ L++; } [/code] [code] int diff1 = strcomp(person[L].first, pivot); while (diff1<0){ L++; } [/code] If you didn't see it, when does diff1 change [i]inside[/i] the loop? | |
Re: [URL="http://msdn.microsoft.com/en-us/library/ybs77ex4(v=vs.80).aspx"]Read Me[/URL]. Either cast the result of the expression, or use a larger type. Typically, there's nothing wrong with using int for all of your signed integer needs to conform to defaults, even if you don't plan to use the full 32-bit range. | |
Re: [QUOTE]I don't know how to call a method from abstract class in protected method.[/QUOTE] Unless the method is static you [I]don't[/I] call it. That's the idea: abstract classes cannot be instantiated and must be inherited from to be used in any useful manner. | |
Re: Good God, can't you STFW? This question is so very common, and has been answered many times even on Daniweb. | |
Re: You're overcomplicating things. Just find the index of the largest value in each array (that's two independent loops), then swap them: [code] int index_of_max(int a[], int size) { int max = 0; for (int i = 1; i < size; i++) { if (a[i] > a[max]) max = i; } … | |
Re: There's nothing wrong with your code, it's the conventional recursive inorder traversal. Perhaps if you explained what you expected to happen that differs from what actually happens, someone can help you change the code to meet your needs. | |
Re: [QUOTE]However because I was in a good mood, I edited your post and removed your real name from it.[/QUOTE] We're usually happy to edit out personal information, if that's the underlying reason for "please delete my thread" requests. |
The End.