6,741 Posted Topics

Member Avatar for terence193

While fgets() suggests reading from a file, you [I]can[/I] pass stdin as the stream for user input.

Member Avatar for WaltP
0
192
Member Avatar for vani krishnan

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?

Member Avatar for vani krishnan
0
143
Member Avatar for mohan_saini

[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 …

Member Avatar for Narue
0
137
Member Avatar for alphahuman

[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 …

Member Avatar for Narue
0
1K
Member Avatar for fmasroor

[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 …

Member Avatar for jwenting
0
310
Member Avatar for asrockw7

[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 …

Member Avatar for asrockw7
0
125
Member Avatar for UNDER-18 FG
Member Avatar for jcAmats

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:

Member Avatar for jcAmats
0
11K
Member Avatar for eblanco1

[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 …

Member Avatar for Narue
0
589
Member Avatar for ooops.789

[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 …

Member Avatar for Narue
0
7K
Member Avatar for JohnQ002

[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 …

Member Avatar for JohnQ002
0
1K
Member Avatar for fmasroor

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 …

Member Avatar for Schol-R-LEA
0
119
Member Avatar for fmasroor

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.

Member Avatar for Moschops
0
535
Member Avatar for Zssffssz

[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]

Member Avatar for mike_2000_17
0
165
Member Avatar for suneye

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 …

Member Avatar for suneye
0
115
Member Avatar for asimnazeer

[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.

Member Avatar for asimnazeer
0
462
Member Avatar for dennisme

[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 …

Member Avatar for dennisme
0
337
Member Avatar for gizmo7008

Your prefix() function signature is jacked up. Fix that and you'll get other errors that are easier to fix.

Member Avatar for WaltP
0
927
Member Avatar for dvidtrnh

[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 …

Member Avatar for WaltP
0
270
Member Avatar for jinna

[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 …

Member Avatar for Narue
0
2K
Member Avatar for sahiti1988

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 …

Member Avatar for Narue
0
214
Member Avatar for CNA Training

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.

Member Avatar for Narue
0
219
Member Avatar for Kobrakai

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?

Member Avatar for Kobrakai
0
163
Member Avatar for gourav1
Member Avatar for gourav1
0
131
Member Avatar for YAMNA MIDHAT

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 …

Member Avatar for YAMNA MIDHAT
0
165
Member Avatar for terence193

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.

Member Avatar for zeroliken
0
112
Member Avatar for learner guy

[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++) …

Member Avatar for learner guy
0
202
Member Avatar for mzimmers

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.

Member Avatar for mzimmers
0
624
Member Avatar for auwi987

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] …

Member Avatar for Narue
0
175
Member Avatar for purpleturtle_97

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 …

Member Avatar for Narue
0
209
Member Avatar for newbie14

[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 …

Member Avatar for newbie14
0
308
Member Avatar for Dani

[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 …

Member Avatar for nalini@121
4
418
Member Avatar for Murugavel B

[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 …

Member Avatar for skatamatic
0
111
Member Avatar for lsvife

[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.

Member Avatar for BitBlt
0
164
Member Avatar for peter20

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.

Member Avatar for Narue
0
243
Member Avatar for XodoX

[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 …

Member Avatar for mrnutty
0
1K
Member Avatar for IT FRESH

[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 …

Member Avatar for Narue
0
192
Member Avatar for bawbawbiscuit

[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 …

Member Avatar for bawbawbiscuit
0
155
Member Avatar for mkab

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); …

Member Avatar for mkab
0
2K
Member Avatar for Dakot

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() …

Member Avatar for Dakot
0
8K
Member Avatar for Kyle Willett

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 …

Member Avatar for Kyle Willett
0
211
Member Avatar for skatamatic

[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 …

Member Avatar for skatamatic
0
2K
Member Avatar for Jack_Frost

[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 …

Member Avatar for Narue
0
171
Member Avatar for Biff123

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?

Member Avatar for Narue
0
122
Member Avatar for Murugavel B

[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.

Member Avatar for Narue
0
129
Member Avatar for Taximus

[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.

Member Avatar for Narue
0
154
Member Avatar for kashyapchhabria

Good God, can't you STFW? This question is so very common, and has been answered many times even on Daniweb.

Member Avatar for Narue
0
204
Member Avatar for phorce

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; } …

Member Avatar for Narue
0
170
Member Avatar for Rubinder singh

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.

Member Avatar for mikrosfoititis
1
169
Member Avatar for SeasideP

[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.

Member Avatar for Nick Evan
0
134

The End.