5,237 Posted Topics
Re: > gives me the correct output but why is this? Because scanf() is full of wonderful surprises - the most usual being that it leaves the \n on the input stream - just ready for the getchar() to return with immediate success. I'd suggest you ALWAYS use fgets() to read … | |
Re: > and my source file is in the same folder as boost. This is a mistake - don't put your code in the same place as third-party libraries. In essence, you should have gcc -I/path/to/boost prog.c Where /path/to/boost is the top-level directory of where your boost header files are installed … | |
Re: In an equally pointless vein [code] // a = a + b while ( b-- ) a++;[/code] OK, so there are some side effects, and a bug or two ;) > I wanted to know the C Statement for adding two numbers without using + sign.. Study what exclusive-or and … | |
Re: Read this, then edit your code to make it presentable [url]http://www.daniweb.com/techtalkforums/announcement8-3.html[/url] You didn't actually ask a question, nor make any suggestion as to what you think is wrong with the code (or the symptoms you get when you do run the code). Just dumping the code on a message board, … | |
Re: There's no need to spam the board either :( [url]http://www.daniweb.com/techtalkforums/thread53563.html[/url] | |
Re: > Thank you so much i actually wasn't to far away with some of the answers, OK, so next time don't look like a complete and utter leech and actually post what you think the answers are rather than just dump your homework and hope you strike it lucky (and … | |
Re: > It works now, You mean "It works [U]for[/U] now" > I type casted the str2.substr(). If you needed a cast to get out of such a small problem, then you've almost certainly done the wrong thing and you're in for problems later on. | |
Re: > printf( "%d%s%s%s%d%s%s%s%d\n", index, delim, deltime, delim, type, delim, filename, delim, filesize ); Something like [code] FILE *fp = fopen( "file.csv", "w" ); fprintf( fp, "%d%s%s%s%d%s%s%s%d\n", index, delim, deltime, delim, type, delim, filename, delim, filesize ); fclose( fp ); [/code] | |
Re: Congratulations on finding a [URL="http://en.wikipedia.org/wiki/Quine"]Quine[/URL]. Just substiute for readability [code] printf( "char*str=%c%c%c;main(){printf(str,34,str,34);}", // str, 34, "char*str=%c%c%c;main(){printf(str,34,str,34);}", // str, 34 ); [/code] The first one contains 3 % conversions for the 3 params which follow The second one is just a string which happens to contain % characters The 'magic' is … | |
Re: > is an assignment like fn4[23] = fn3[5] invalid? Well it's fine as far as the syntax is concerned. However, the pointer inside the structure presents big problems. [code] fn1.y = malloc( 10 * sizeof *fn1.y ); fn2 = fn1; free( fn1.y ); // fn2.y is now a dangling pointer. … | |
Re: > Just ignore that one -- it only means your program failed to compile and link correctly ROFLMAO - good one. It's like trying to explain fire to a caveman. It doesn't matter what you say, all they can do is "oooh" at the pretty colours and "argh" when they … | |
Re: Wow - 3 in a row. [url]http://www.daniweb.com/techtalkforums/announcement8-2.html[/url] | |
Re: > while((i=fgetc(ptr))!=Null) As well as the EOF thing, i should be an int, not a char. It needs to be capable of storing all 256 possible values of char AND EOF (257 different values in total). | |
Re: > new is a keyword which cant be used as a variable True, but this is C, so it's OK. There's some good stuff in there ~s.o.s~ Here's some more for the OP to think about. > while(new->cus_ac_no > p->cus_ac_no You're comparing two pointers here, not two values. In general, … | |
Re: > int taco,pizza,chicken,hamburger,hotdog,; Does this even compile? That trailing , looks like a syntax error to me. > the only thing i can think of is that there might be something wrong with the compiler. Er, no - it's all your code. The chance of a newbie stumbling on a … | |
Re: [URL="http://cf31.clusty.com/search?v%3afile=viv_505%4031%3alVNcqL&v%3aframe=list&v%3astate=root%7cN865&id=N865&action=list"]click me[/URL] My guess is you tried to pass a C++ function as a "pointer to function" which is expecting a pointer to a C function. Perhaps some of the links will have more ideas, I didn't read them all. | |
Re: Yes, it's the Fibonacci series [url]http://en.wikipedia.org/wiki/Fibonacci_number[/url] Read this first [url]http://www.daniweb.com/techtalkforums/announcement8-2.html[/url] Then post your attempt at a solution, then we can offer some useful suggestions on how to proceed. | |
Re: As if bumping an old thread wasn't bad enough, you had to use gets() and atoi() to do it. | |
Re: > I am not sure the formula for average here Elementary maths perhaps? You add up all the elements in your array - use a for loop You divide the total by how many elements there are | |
Re: Like [inlinecode]3 = myVariable;[/inlinecode] Will generate an lvalue error, because you can't assign to a numeric constant. You can't assign to a function, or assign to an array either. | |
Re: > cout<<endl Until you fix ALL the compilation errors, you cannot debug your program. Also, you use /n where you probably mean \n | |
Re: > but the 19.95 and 246.50 display 0.00 Perhaps it's because of this bizarre line of code > bookPrice = ( price > 0.00 ) ? 0.00 : price; If the price is greater that zero, set it to zero. | |
Re: > I keep getting a message that there is not an exe. file. What is causing this? Exact details please, not some vague "there's an error". This means - State your OS and compiler, with versions (not just windows and borland say) - An example simple program which shows the … | |
Re: [url]http://www.daniweb.com/techtalkforums/announcement8-2.html[/url] | |
Re: > actually leads to the assignment of value at s2 to s1 Yes, s2 is dereferenced to yeild a value, and that value is stored to where s1 points. > followed by incrementation of s2 then the incrementation of s1. That's less clear [url]http://c-faq.com/expr/seqpoints.html[/url] Which order they happen in, and … | |
| |
Re: > int **EL= (int**)malloc(row*col*sizeof(int) + col*sizeof(int*)); 1. You didn't include stdlib.h 2. Since this seems to be C++, you should be using new anyway. 3. Since your sizes seem to be constant, why are you dynamically allocating anyway? I see that lot adds up to at least a couple of … | |
Re: [url]http://www.daniweb.com/techtalkforums/announcement8-2.html[/url] | |
Re: > It never outputs that the startup has failed, so I don't believe that's the problem... I bet the following call to cleanup() before you get to do any real work has something to do with it. | |
Re: [code] char* query = "SELECT %s FROM Table"; char newquery[100]; char* repl_val = "VariableFieldName"; sprintf( newquery, query, repl_value ); [/code] Any particular reason why you can't do this? | |
Re: More like the same message is spammed in many different forums (too many to remember, let alone revisit), so they're just sat there waiting for the inbox to magically reveal someone who will send them an answer. Of course, once you do this, they will attach themselves in some leech-like … | |
Re: > I was wandering is linked list the best solution? There isn't a "best" solution as such, there are many tradeoffs to be considered. Some of which are not so obvious. Well the search/replace is going to be expensive on larger lists, but that has to be weighed against the … | |
Re: > Same Error's Just Fractionaly Diffrent Please stop capitalising every initial letter of every word. [url]http://www.catb.org/~esr/faqs/smart-questions.html#writewell[/url] | |
Re: State your OS / Compiler, and what you tried to do, and say what you don't like about your current approach. | |
Re: What happens if the same word appears on a single line more than once? You could try [inlinecode]map<string,vector<int> >[/inlinecode] to associate a word with a list of line numbers. | |
Re: 1. Your class it at least missing it's closing ; 2. By failing to use code tags, certain class member functions have been replaced by smilies. 3. Why on earth are you still using char* to store strings. This is C++, and you already include <string>, so why not just … | |
Re: > #include "stdafx.h" Delete this from the project and disable "Use precompiled headers" in the microsoft compiler. > #include <malloc.h> This is an obsolete file, you don't need this. malloc etc are declared in stdlib.h You're also missing stdio.h and string.h > (69) : error C2664: 'FindFirstFileW' : cannot convert … | |
Re: > char *bin; Listen to the people - you need to allocate some memory. You can't just declare a pointer and assume you have an infintely long string you can play with at will. This is just some random location in memory. Start with [inlinecode]char bin[100] = { 0 };[/inlinecode] | |
Re: "Threepio! Shut down all the garbage mashers on the detention level! Shut down all the garbage mashers on the detention level!" Here's a project for someone. "close thread where title is matched by "project" and age is greater than 3 months". That should slow down the "me too" brigade from … | |
Re: > char *second=string2(string2,"|"); Huh - did you mean strtok() Also, you're not calling strtok() correctly either. You can't strtok() two strings at the [u]same time[/u]. Remember that NULL parameter means use where you got to last time. So you must get to the end of the first string before trying … | |
Re: > How to swap two variables without using a third variable & pointer? This ceased to be interesting when we came down from the trees and started using high level programming languages. If your "teacher" somehow thinks this is a good idea you need a better teacher. [url]http://en.wikipedia.org/wiki/Xor_swap[/url] Way too … | |
Re: /usr/bin/gdb This is the command line debugger. /usr/bin/ddd This is the 'visual' wrapper around gdb. You can use this to point at lines of code, insert breakpoints, examine variables etc. | |
Re: > cout<<(j++)&&(i++); What does this output - with extra ( ) cout<< ((j++)&&(i++)) ; If it's 0, look up the operator precedence table in your handy book. | |
Re: > Why the reverse output? Make sure you understand the consequences of the link posted by WaltP Even though you might be able to come up with an explanation of why the output is reversed, there is no telling what would happen in any similar circumstance. Undefined behaviour is very … | |
Re: Well you could help yourself by telling us which actual error messages you see. > am compiling it in turboc Ah, good old stone age technology - have you sharpened the stone chisel recently? I'm also guessing you don't know the answer to the question "are you compiling C or … | |
Re: So just add the centre (cx,cy) to your calculations [code] r * cos(theta) + cx; r * sin(theta) + cy; [/code] | |
Re: > send me a program to remove unnecesary space from a string in turbo c++ Who gets to decide what is "unnecesary" ? Read this [url]http://www.daniweb.com/techtalkforums/announcement8-2.html[/url] Then make an effort. | |
Re: > xss.exe - 4 error(s), 0 warning(s) > void main As well as being wrong (see previous posts, it should be int), you're specifically saying that NO value should be returned. Yet later on (4 times to be precise), you have a return 1; etc. This isn't void, so the … |
The End.