5,237 Posted Topics
Re: Well some context for the code would help. Like how did you declare the num array? How did you get data into it? How did you print it out? It looks about right "as is", so I can only assume the mistake is somewhere else. | |
Re: > [inlinecode]typedef int **ppMYARRAY[7];[/inlinecode] Thats array of [7] pointers to pointers to int [inlinecode]typedef int *(*ppMYARRAY)[7];[/inlinecode] pointer to an array of [7] pointers to int There's a program to help with the complicated ones. [URL]http://packages.debian.org/stable/devel/cdecl[/URL] Here's an article on how to read those complex beasties. [URL]http://www.codeproject.com/cpp/complex_declarations.asp[/URL] | |
Re: > void printarray(int **,int); > void printarray(int *array[],int); Neither of these are valid for passing a true 2D array. [code] void foo ( int **p ) { } void bar ( int *p[] ) { } void baz ( int p[][7] ) { // p[3][7] would also work } void … | |
Re: First of all, your function pointer MUST be declared to be exactly the same as the function you're pointing at. Declaring int where it expects two char*'s for example isn't the way to go. Second, use typedef's for function pointers. I usually avoid typedefs for pointers, but function pointers are … | |
Re: > Also, this looks like it can only generate the machine code, rather than C code? True, and it's also specific to the MIPS processor as well, which means that at best, it will only turn a MIPS a.out file back into MIPS assembly, which might give you a chance … | |
Re: > I have an idea but i am not quite sure. So explain your reasoning, and then we can tell if you're on the right track. | |
Re: [URL]http://www.daniweb.com/techtalkforums/thread61192.html[/URL] So have you made ANY progress at all in the last 10 days, or are you just going to keep posting the homework until you get an answer? If it's only urgent now because you've been sitting around waiting for someone else to do the work, then that's your … | |
Re: At the risk of stating the obvious [url]http://en.wikipedia.org/wiki/Roulette[/url] Maybe a little research on the nature of the probabilities (and the odds, which are not the same thing) is in order. | |
Re: Goto project settings and turn off precompiled headers would be my suggestion. For a feature which is supposed to improve productivity, it sure provokes an awful lot of questions from all sections of the community. | |
Re: 1. Please use the [code][/code] tags when posting code. It isn't like there aren't enough hints for you to do this. 2. You also need to give a better description of the problem than "it doesn't work" followed by simply dumping your code on the message board. How "doesn't" it … | |
![]() | Re: Seen it [url]http://forums.devshed.com/c-programming-42/problem-with-selection-sorting-program-403357.html[/url] |
Re: Post your code, then perhaps we can tell you where you went wrong. Don't forget to use the tags around your code. ![]() | |
Re: Well if you do [code] pid = fork(); if ( pid == 0 ) { // in child, do child specific stuff } else if ( pid != -1 ) { // in parent, do parent specific stuff } else { // in parent, but fork failed } [/code] Then … | |
Re: Sort of possible, but not recommended [code] #include <iostream> #include <string> #include <cstdlib> using namespace std; void MyFunc(int **my_array) { for ( int i=0; i<10; i++) (*my_array)[i] = i; } int main() { int int_array[10]; int *temp = int_array; MyFunc( &temp ); // was &int_array cout << int_array[0] << " … | |
Re: Yes, start a new thread, and this time make sure you use the code tags. Do you see the watermark in the background of the edit window, telling you how to use code tags? Have you even read this - [url]http://www.daniweb.com/techtalkforums/announcement8-3.html[/url] Did you bother to press "preview" before "submit" ? | |
Re: > but she has no idea what she's teaching. We get that a lot. [url]http://faq.cprogramming.com/cgi-bin/smartfaq.cgi?answer=1044841143&id=1043284376[/url] It's only crappy DOS compilers which ever had this, presumably because DOS was so crappy at dealing with the return value that nobody ever cared. All real compilers only accept int main, which is the … | |
Re: > [COLOR=#b1b100]switch[/COLOR] [COLOR=#66cc66]([/COLOR]number[COLOR=#66cc66])[/COLOR] With a suitable table of values (ie, an array), you could do all this with one line [inlinecode]board ^= table[number];[/inlinecode] | |
Re: Is that really your code, because it won't even compile. | |
Re: > char name[]; This isn't some "magic" variable length array you can just scribble chars into with strcpy. Making it char* won't help much either, unless you want to manage memory yourself. Personally, I'd go with [inlinecode] std::string name;[/inlinecode] Then your member functions can be like this [code] Player( std::string … | |
Re: > undefined reference to `WinMain@16' It definitely thinks it is a GUI program somewhere along the line. | |
Re: First it was bumped Then it was off-topic Now it's closed. | |
Re: This [code] void func() { static int i = 0; cout << "i = " << ++i << endl; } [/code] Is like this [code] static int i = 0; void func() { cout << "i = " << ++i << endl; } [/code] With the exception that the scope … | |
Re: > i wouldn't use atoi. Try stringstream. Yes! use a string stream if you're using C++. If you must use a C function, at least use strtod() which has some error checking capabilities. | |
Re: > I have a function to find out if a number is prime or not. Which isn't working. > bool isPrime(int n); Where is your implementation of this function? This is step 1 [code] bool isPrime(int n); int main ( ) { for ( int i = 1 ; i … | |
Re: > "Indenting? Nah, that's a waste of time-- I don't care if its all pretty. It just matters that it runs." That might work in the "write once, read once, run once" code which is the average student assignment, but in industry where code has a much longer lifetime (and … | |
Re: A fat lot of good that did! Added code tags, but it's still unindented crap. > [B][B][B]I would liike to multiply two matrices but my code is not working..help me out![/B][/B][/B] Post a proper question. Don't just dump the code and hope someone will figure it out. Does it compile? … | |
Re: Opening the same file for input and output at the same time is not a good idea. open for read read it close it do stuff open for write write it close it. | |
Re: This forum is for C and C++. What you've posted seems to be visual basic. | |
Re: Since check is a boolean, you may as well do [INLINECODE] if ( check )[/INLINECODE] I personally dislike the swapping over of variables in an attempt to get an error message on the mis-use of = | |
Re: There's nothing which states all pointers must be the same size [url]http://c-faq.com/null/machexamp.html[/url] | |
Re: > HWND hTemp = FindWindow("tibiaclient", NULL); The newer compilers use UNICODE by default. I think you can either turn this off. Or prepare your code for the future by writing HWND hTemp = FindWindow( _TEXT("tibiaclient"), NULL); [URL="http://www.i18nguy.com/unicode/c-unicode.html"]http://www.i18nguy.com/unicode/c-unicode.html[/URL] | |
Re: > i m wrking on linux Most shells do this for you, the usual question being "how do I turn OFF" wildcard expansion. If you have a.txt b.txt and c.txt in your directory, then doing myprog *.txt Will invariably result in your program seeing argv[1] = "a.txt" argv[2] = "b.txt" … | |
Re: [code] // file = fopen(filename.c_str()); // MAKE CODE CHANGE HERE char ch; // char ch; int counter = 0; // int counter=0; char* str; // string str; while(!(feof(file))) // { do { ch = fgetc(file); str = str + ch; [/code] Well the first thing is to decide whether you're … ![]() | |
Re: > scanf[COLOR=#66cc66]([/COLOR][COLOR=#ff0000]"%f"[/COLOR],loan[COLOR=#66cc66])[/COLOR]; You forgot the &, like [INLINECODE]scanf[COLOR=#66cc66]([/COLOR][COLOR=#ff0000]"%f"[/COLOR], &loan[COLOR=#66cc66])[/COLOR];[/INLINECODE] Ditto for the years. You also need to call your Mortgage_Calc function at some point. | |
Re: The inner printf is missing an int parameter to make the %d do something meaningful! | |
Re: Search harder? [url]http://clusty.com/search?query=convolution+dsp+c+source+code[/url] | |
Re: > putting in the comma and quotes are certainly not the most pleasant things to do Wrap it up in a class :) Probably not a bad idea if you need to do this a lot. | |
Re: Reposted again (or was it before) [url]http://www.daniweb.com/techtalkforums/thread59090.html[/url] Anyway, this dupe is closed. | |
Re: > and still get fn() to recognise its existance? Pass it as a parameter. Unless this is one of those futile exercises that some tutors seem to love (for god-knows what reason), and the answer usually involves some horridness involving macros. If this is the case, then perhaps consider a … | |
Re: Having read a line from the user, you normally have to remove the newline before trying to use it as a filename. [code] if ( fgets( buff, sizeof buff, stdin ) != NULL ) { char *p = strchr( buff, '\n' ); if ( p ) *p = '\0'; fp … | |
Re: To open a file in binary mode [inlinecode] FILE *fp = fopen("image.bin","rb");[/inlinecode] To read a byte from the file [inlinecode] int ch = fgetc( fp ); if ( ch != EOF ) { /* do something */ }[/inlinecode] Reading the whole file extends to [inlinecode]while ( (ch=fgetc(fp)) != EOF )[/inlinecode] … | |
Re: The web (for want of being searched) has several articles on how to get something 'OO' going in C. [url]http://clusty.com/search?query=oop+in+c&sourceid=Mozilla-search[/url] | |
Re: > I need a general answer, not depending on any code... If you're looking to get things like the return address, base pointer and stack pointer say, then there is NO general answer. It is very compiler specific, right down to which set of compiler flags you specify. | |
Re: > while (num=0) Use == for comparison, = is for assignment Though you probably want != > return (sum); Think - would this be better inside or outside of the loop. > reverse(int num); This just prototypes the function again. Try say [inlinecode] sum = reverse( num );[/inlinecode] | |
Re: Because you need to look-ahead, it's probably better to read the whole string into memory. Then if you're looking at an 'i', you can look at the next character to see whether it is another 'i', or a 'v' or an 'x', then decide what to do about it. | |
Re: [code] class DownSample { public: Matrix *downSmple(Matrix *Image); } ; // <----- this ; is MISSING [/code] | |
Re: How long does an empty loop take? [code] while (getline(inFile, s)) { } [/code] Separate the "time to read the file" from the time to "tokenise the file". It it takes <1 second, then there might be something you can do. If it takes >3 seconds, then all your tokenising/vector … | |
Re: > printf(" user time: %d microseconds\n", sutime); Go read the manual page for printf conversions again - %d is NOT for doubles. If you're using gcc as your compiler, then add these flags to the command line [INLINECODE]gcc -W -Wall prog.c[/INLINECODE] It will then tell you when the printf/scanf format … | |
Re: > int binconvert (intNum) 1. Give the parameter a type - say int 2. Actually use the parameter inside the function. | |
Re: > if (transmissionflag = 0) break; else; Maybe use == for comparison? |
The End.