- Strength to Increase Rep
- +8
- Strength to Decrease Rep
- -2
- Upvotes Received
- 31
- Posts with Upvotes
- 25
- Upvoting Members
- 21
- Downvotes Received
- 2
- Posts with Downvotes
- 2
- Downvoting Members
- 2
78 Posted Topics
Re: My industry experience is not impressive and not in your industry, so take the following with a grain of salt. I once knew a developer for a major company who would often travel to deliver training lectures for corporate clients. You might research companies that offer training for their product … | |
Re: Second what WaltP says, plus don't use scanf for interactive user input, check the return values of standard library functions, and use fflush(stdout) after printing a prompt that doesn't end with '\n' to make sure it gets printed. 1 is not a portable value to pass to exit(), and returning … | |
Re: > I may be mistaken but I believe you have to by *\[sic]* QT If the rest of your post is also 12 years out of date, I'm not sure why I bothered reading it. > Few would be developing VB.net apps with GUIs without using an environment that removes … | |
Re: > there is no problem to do backward or frontward in single linked, as long as it is only one way to go needed, is more needed is both or one ? or you just go from start agayn to that spot you need. Or depends how much back you … | |
Re: Ancient Dragon is correct, but I'd like to point out that there is a difference between char *str = "Test"; /* and */ char str[] = "Test"; In both cases, "Test" is a string that resides in read-only memory. In the first case, `str` is a pointer object that is … | |
Re: I agree with pyTony, recursion seems like an odd way to solve this problem. However, you should be able to get your original version to work if you give it an array that can be modified (untested): int main(void) { char *charset="abcdefghij"; char buffer[100] = ""; recurse(buffer,charset); } When you … | |
Re: Which is why you should instead use array = malloc(ROWS * sizeof *array); Also don't cast the result of malloc(), it suppresses warnings and serves no useful purpose. deceptikon's solution was in every way superior. | |
Re: $x += $y means the same thing as $x = $x + y with the exception that `$x` is evaluated only once -- this would only make a difference if evaluating $x had side effects (e.g. when it's not really a variable but actually a subroutine call). You can use … | |
Re: I'm going to guess you meant to post something more like this: #include <stdio.h> int main(int argc, char *argv[]) { if (argc != 2) { printf("usage: %s filename", argv[0]); } else { FILE *file = fopen(argv[1], "r"); if (file == 0) { printf("Could not open file\n"); } else { int … | |
Re: Schol-R-LEA has an overall good analysis. I'll comment on three points. * Everybody you ask will have a different opinion on what editor or IDE to use. Personally I use Vim but I usually recommend jEdit for newbies; it has a good user interface, available on anything Java runs on, … | |
Re: You didn't ask a question, so I'm assuming you want feedback. * `void main()` is a non-standard extension to the C language. Prefer `int main(void)` (or `int main(int argc, char *argv[])` when you want to use command line arguments). * `<conio.h>` is also non-standard and also very very old. Don't … | |
Re: When you declare an array (or any object) within a function, the memory allocated for it has *automatic storage duration*, meaning that once the name it was declared with goes out of scope, trying to access the memory (via e.g. a persistent pointer, like you have done) results in undefined … | |
Re: Why do you need an array that size? How would you rewrite your program so that such a large array is not necessary? | |
Re: Nope. The first part of a 3-statement `for` clause is run only once, before the first test or the first execution of the loop body. The equivalent would be more like mytype = 500 for x in range(filearray_count): ... That said, 500 seems to be somewhat arbitrary since you don't … | |
Re: Nope. If you want it to do something when you run it from the command line, you need to put code in the top level of the file (not in a function). You can easily make your script behave this way, though, if you add the following code to it: … | |
Re: This looks odd to me: foreach $line (@L1) { $line =~ s/,,,/,/g; print @L1; } Sure you want to print all of @L1 every time through that loop? As for your output, I can't tell what you expect it to do. Could you post your input and describe what you … | |
![]() | Re: The question has been marked as solved, so I don't know whether you're still expecting answers... When you find yourself calling static methods from non-static methods or vice versa, it means you haven't thought about the problem enough. You actually answered your own question after a fashion, if you take … ![]() |
Re: Since you're not instantiating any objects of class Die, *anything* you want to use must be declared `static`. That includes all the variables that are defined directly within the class as well as the die() method. That said, you don't have code showing how you expect to use the Die … | |
Re: Easiest C version, guaranteed. Probably won't work under Windows though. #include <stdio.h> #include <stdlib.h> char const * const lines[] = { "my %files;\n", "while(<>) {\n", " my($index) = /(\\d+)$/;\n", " $files{$index} .= $_;\n", "}\n", "for(keys %files) {\n", " open OUTPUT, '>', \"File$_.txt\";\n", " print OUTPUT $files{$_};\n", " close OUTPUT;\n", "}\n", … | |
Re: For values of `voltage` less than 4200, you'll always get zero. This is because of the way integer arithmetic works. [Relevant C FAQ link.](http://c-faq.com/expr/truncation1.html) | |
Re: That's certainly one *valid* way to pass multiple values to a function, but it's not *advisable*. Your proposed solution is overly complicated, which makes it hard to document, hard to read, and hard to debug. Furthermore, it seems in your case to be totally unnecessary. Since you're not doing anything … | |
Re: > I'm using VS2010 compiler. when i use as above statement it didnt give any build error. it built fine and execute fine Cool story bro. According to section 6.4.4.4 of C99, the behavior of a multi-character single-quoted constant like '50' is implementation-defined. A diagnostic is not required in this … | |
Re: Do you see why the result is 0x1.9cccccp3? I don't think you can do any better than that with the standard library. Converting fractions into other bases is not a very common need (unlike integers, which are quite handy to have in base-N sometimes.) What you might do with a … | |
Re: You mean like [CODE]System.out.printf("%4.2f\t%4.2f\n", var1, var2);[/CODE] Check out the Java API for PrintStream and Formatter to see details on printf. | |
Re: I think I understand why -- printf("%s\n", s) can be optimized to puts(s). That said, this is EXACTLY why you shouldn't ever rely on undefined behavior -- because it does weird things you can't predict and is affected by apparently unrelated changes in ways you can't anticipate. Any attempt to … | |
Re: I'm trying, but I can't figure out how your output follows from your input. Can you explain the problem more clearly? | |
Re: atoi() has no way to recover from errors. Use strtol() as subith86 suggested. Should you actually want to test whether a character is a digit, don't perform contortions; #include <ctype.h> and use isdigit instead. | |
Re: Generally speaking, anywhere in C you would see a call to malloc(), in Java (or C++) you'll find the word [B]new[/B] instead. This also applies for strings, but strings are a little bit special in that there is a unique syntax for creating them (using "...") that doesn't use [B]new[/B]. … | |
Re: [CODE]WELCOME TO FORUMS, puppycrazy WOULD YOU LIKE TO ANNOY YOUR USERS?(Y/N) : y IN THAT CASE PLEASE CONTINUE USING ALL CAPS WOULD YOU LIKE TO GET GOOD ANSWERS?(Y/N) : y IN THAT CASE PLEASE CONSIDER PROOFREADING YOUR POSTS TO ENSURE THEY MAKE SENSE. ALSO,PLEASE!AVOID>USING~WEIRD.......><....PUNCTUATION, SPACES EXIST FOR A REASON[/CODE] | |
Re: [QUOTE=3435;1725525][B]Hello everyone!![/B] I am new to Linux forum and have a question related to typecasting in C related to offset of structures. <snip>[/QUOTE] Typecasting is something that happens to actors... | |
Re: Have you noticed that n is only ever zero at the beginning of the program? I'm not 100% sure I understand the purpose of it, but I think you should at least reset it on each iteration of the while loop. Furthermore, what happens when tmp ends up pointing to … | |
Re: Careful of file extensions, too. Windows will mess you up sometimes... if you save something with the extension, make sure it saves as values.txt and not (say) values.txt.java (this shouldn't happen with any IDE I'm familiar with, but you never did say how you created the file). | |
Re: Homework detected, even though you haven't asked a question yet. If this were real code, I'd say go ahead and use goto. The reasons to avoid doing so don't really apply in this particular situation, and it saves time, space and clutter. | |
Re: What kind of image? PNG? Bitmap? Some other format? | |
Re: I don't want to solve your homework problems for you, but maybe I can point you in the right direction. Your problem is that findName finds only the first matching line in the file and returns, correct? So you need to make findName somehow return as many lines as are … | |
Re: "Advanced Java" really doesn't mean anything. I'm guessing it's a class, something like my CS2 class, in which you're still going to be dealing with the ins and outs of the Java language. In other words, probably not looking at hibernate, spring or any of that stuff, and really only … | |
Re: Looks like homework. What are the contents of data_list? What do you need to do to each one? | |
Re: I see what your problem is... but the advice I'm going to give is going to be more useful in the long run than telling you straight. [CODE]# after 'use strict' use Data::Dumper; # then in your code, when you want to see the contents of %seqs warn Dumper(\%seqs);[/CODE] Put … | |
Re: [QUOTE=Gribouillis;1722771]@valorien: also read this as an alternative to the shebang line: [url]http://www.daniweb.com/software-development/python/code/241988[/url][/QUOTE] This sounds like a bad idea. Non-portable, and it means all your Python scripts have to end in .py (and if by chance you were to have an actual binary end in .py you wouldn't be able to … | |
Re: Use code tags instead of quote tags to preserve formatting. The code you've posted doesn't describe the structure you've said it does. => is just syntactic sugar for a comma, so $chainStorage->{ACB} is [CODE]{ E => '06', [100, 200, 95] => 'B', '23' => [20, 1000, 5, 30], }[/CODE] Assuming … | |
Re: Can you be a little more explicit about the program requirements? Like, what should the file look like before and after updatefile() is called, in a sample run? The sample code you've written would overwrite anything already in the file, but you called it "update", so... I'm a little puzzled. … | |
Re: const-qualified variables aren't the same as constants. [code]int const i = 5;[/code] 5 is a constant. i is a variable that happens to be const-qualified, which means you can't modify it directly. Constants can never be modified, because at runtime they usually don't exist. const-qualified variables, well, it depends. const … | |
Re: [QUOTE=Paritosh Das;1459746][CODE]#include<conio.h> #include<graphics.h> #include<dos.h> void main() [/CODE][/QUOTE] I'm assuming those three headers provide all the undeclared identifiers in your code. Care to share with us where they come from? main() returns int. | |
Re: [CODE]printf("Enter the weight in pounds> "); scanf("%lf", £s);[/CODE] Two notes here. First, there's no \n, so the implementation isn't obligated to print the prompt before waiting for input; use [icode]fflush(stdout)[/icode] to make sure it works regardless. Second, check the return value of scanf() to make sure your zero is actually … | |
Re: userRequest is local to getCommand, which means its memory disappears when control returns to main(). strtok() doesn't allocate new memory -- it just zero-terminates a token in the source string and returns a pointer to its first character. Therefore all the addresses in the parameters array are invalid when getCommand … | |
Re: [QUOTE=Madmark88;1456013] [CODE]#include"stdio.h" #include"conio.h" #include"math.h" int main(void) { int a,b = 0; int c=0; printf("Please enter a number : "); scanf("%d",&b); for(a=0;a<1000;a++) { c=(a*a*a)-(a*a); if(b==c) { printf("%d",a); } } getch(); } [/CODE][/QUOTE] For starters, get rid of that conio.h and getch() nonsense, and use angle brackets to surround standard header files, … | |
Re: [QUOTE=WaltP;1454293]But [iCODE]ungetc()[/iCODE] is non-standard and therefore not recommended. It will not work in most compilers.[/QUOTE] Standard section 7.19.7.11 (The ungetc function) begs to differ. | |
Re: Try [url=http://tinyurl.com/46mattc]here[/url]. I have plenty of projects of my own to do, thanks very much. | |
Re: I could tell you how I would do it, but it smells like homework and something you should be working out on your own. If you have specific problems, post [B]complete, compilable code[/B] and ask specific questions. |
The End.