3,183 Posted Topics
Re: What are the advantages of a single pointer? Answer that and then you have the answer for double, triple, quadruple, etc. pointers. | |
Re: [QUOTE]Hypotheticaly, if you have a large object that is needed almost everwhere within a program and this object is used for accessing data. Is it better to pass the object by referance into each function that needs it, or to make the object static?[/QUOTE] Hypothetically, I'd question whether that large … | |
Re: They're hexadecimal. 0x is a common prefix for hexadecimal. You'll also see a suffix of h. But the telltale sign is letters. | |
Re: If the checkbox should be checked, add checked="checked" to the input tag attributes: [code] <input type="checkbox" name="foo" value="1" <?= $foo ? 'checked="checked"' : '' ?> > [/code] | |
Re: %s prints the whole string. If the starting point for the string steps ahead by one character each iteration, you basically chop off the first character each time. [code] char const* x = "Alice"; printf("%s", x); // "Alice" ++x; printf("%s", x); // "lice" ++x; printf("%s", x); // "ice" ++x; printf("%s", … | |
![]() | Re: [QUOTE]That's because you are new and haven't developed the keen Spidey Programming sense yet. It'll come...[/QUOTE] How long does that take? Because I've been programming for well over 10 years and still have a dull Spidey sense. :D |
Re: The for loop is completely nonsensical. It's like this: [code] for (initialization; condition; increment) { body } [/code] Where the roughly analogous while loop is: [code] initialization while (condition) { body increment } [/code] So your loop, [icode]for(i<=5&&i>=-1;++i;i>0) printf("%u",i);[/icode] would look something like this while loop: [code] i <= 5 … | |
Re: The compiler is right. Sports is a class name, and you can't use it to call a non-static method. To call getName() you first need to create an object of the Sports class. | |
Re: The [B]text[/B] of a macro argument is used, not the value of the variable. So after expansion the statement is: [code] int i = ++x * ++x; [/code] On top of being undefined behavior, that's probably not the logic you intended. Any expressions with side effects should be avoided as … | |
Re: If you're not getting any errors but the image is broken, the URL is probably wrong. First make sure that $pic represents a file name that exists in the site_images directory, then make sure that that whole URL is accessible to the page as written. | |
Re: I don't have any tips because you didn't explain what the program is supposed to do. It's not safe to assume that anyone here knows what an anti-saccade task is, much less infer your program's requirements from that even if they did. | |
Re: It all looks good to me. To answer G, your answer for D will help. Just remember that it's a nested loop and the solution will be apparent. :) | |
Re: [QUOTE=sharathg.satya;1742733]I saw this example while i am searching about vectors.. [CODE] vector<double> student_marks; // no size specified: vector contains // no elements int num_students; cout << "Number of students: " << flush; cin >> num_students; student_marks.resize (num_students); for (vector<double>::size_type i = 0; i < num_students; i++) { cout << "Enter … | |
Re: May I suggest the OpenPOP library? I've used it in several projects and haven't had any problems yet. | |
Re: [QUOTE=BobS0327;1742201]The solution to your problem is to use the memcmp function as a comparison of your structures. I do realize that this is somewhat of an unorthodox solution. But it does work. I did put together some proof of concept code to verify that it does in fact work. Unfortunately, … | |
Re: [QUOTE=sharathg.satya;1742626]Is it an old idea to compile and run c programs on turbo c?[/QUOTE] Yes, by about 15 years. Visual C++ is freely available, Code::Blocks comes with a recent gcc build, and I hear Pelles C is good too. There are more, but those are the three most common recommendations. | |
Re: [URL="http://www.daniweb.com/forums/faq.php?faq=daniweb_policies"]Daniweb's Rules[/URL] | |
Re: [QUOTE=sharathg.satya;1742515]ok the only reason is it may cause problem when it is used in any other compiler or version[/QUOTE] There are two big reasons: [list=1] [*]The new operator calls constructors and the delete operator calls destructors. malloc() and free() only work with raw memory. So if you use malloc() to … | |
Re: If it's not a library that was built for Windows, you won't be able to use it. | |
Re: The assembler would be written in another language first, possibly a different assembly language or even a higher level language like C. Then it's not uncommon after that for the assembler to compile/bootstrap itself as a way of shaking out bugs and proving viability of the tool. And since it's … | |
Re: [QUOTE]As a matter of fact the output of my quicksort program is correct.[/QUOTE] Unfortunately, in C "working" is not a guarantee of correctness. The swap process is undefined. Take [ICODE]a[hi]=a[pivot]+a[hi]-(a[pivot]=a[hi]);[/ICODE] as an example. In C you can't assign to a variable and then use it again for anything except to … | |
Re: In [ICODE]{ echo ' selected="selected" }[/ICODE], the PHP string isn't closed. | |
Re: It all depends on how the file is formatted and how deeply you want to scan. If the int is a word of its own and not part of a larger word, you can just read words and check for the int: [code] #include <stdbool.h> #include <stdio.h> bool is_int(char const* … | |
Re: I wouldn't use recursion for this, but that doesn't mean your way is wrong if it does the job. | |
Re: [URL="http://stackoverflow.com/questions/757675/website-screenshots-using-php"]Website screenshots using PHP[/URL]. | |
Re: [QUOTE][CODE]double **matrix = new double*[rows*sizeof(double*)];[/CODE][/QUOTE] This line declares a new matrix variable that hides the one defined in your class. After the constructor runs, the matrix variable defined in your class is still uninitialized. [QUOTE][CODE]for(int i=0, j=0; (i < rows, j < columns); i++, j++)[/CODE][/QUOTE] I don't think this does … | |
Re: It totally depends on how the compiler organizes memory. In gcc the string literal "%s" is stored after the string literal "dcis" in memory, so overrunning the string prints "%s". You can test it like this: [code] #include <stdio.h> int main(void) { const char *before = "before"; const char *p … | |
Re: [QUOTE=Captain Jake;1741047]What i asked is, how to write the the code, which don't give a undefined behavior still giving the correct output for this exact question.[/QUOTE] The undefined behavior comes from modifying the same variable more than once in the same expression. To get rid of undefined behavior, first figure … | |
Re: If the constructor depends on a pointer then it should make a copy in all cases or in no cases. That way the class is guaranteed to always own the pointer and deleting it is safe, or the pointer is always assumed to be owned by an external entity and … | |
Re: Why not use String.Replace()? [code] string NewDate = Date.Replace(".", string.Empty); [/code] | |
Re: The = operator is for assignment in C++. You want the == operator to compare equality: [code] for (x = 0; x <= y; x++) { if (a == x || b == x || c == x) { printf("Value = %d", x); } } [/code] | |
Re: Strings are immutable in C#. If you want something more like an array, use a StringBuilder object: [code] var x = new StringBuilder("Daniweb"); x[3] = 'k'; Console.WriteLine(x.ToString()); [/code] |
The End.