1,171 Posted Topics
Re: [QUOTE=niek_e;982627]Exactly. One of the other typos I still make now and then is : [icode]if (a[COLOR="red"]=[/COLOR]1)[/icode] versus [icode]if (a[COLOR="red"]==[/COLOR]1)[/icode] Which can also give you a headache..[/QUOTE] Yea, but if you write it like this: [ICODE]if(1 = a)[/ICODE] your compiler will report it as an error, saving you much headache :P | |
Re: Could you maybe explain us first what the goal of the program you posted is? (I mean: what output do you expect, etc.) To answer the question in your signature: [QUOTE] Yo god, where do i report a bug? [/QUOTE] Start a new thread about the bug in the [URL="http://www.daniweb.com/forums/forum26.html"]DaniWeb … | |
Re: You mean that the output on your screen has to look like this: [ICODE]\n[/ICODE] ? In that case, you just print the following string to your screen: [ICODE]"\\n"[/ICODE] :) | |
Re: Hi johnab2112, Welcome to Daniweb I hope you're liking your stay here as much as I do. I can assure you that you can learn loads of things here from very knowledgeable people (only a minor effort is required). Looking forward to see you participating in the discussions here :) … | |
Re: [QUOTE]An example to the question I don't know: To turn bit 3 of a variable to 0. the correct way is to: Ans: Not sure how to do but I think I know it involve some thing about Mask and flags.[/QUOTE] [U]Short answer:[/U] take a value where all bits (except … | |
Re: [QUOTE=Miganders;978855]how to make something like this work? if (KeysPressed="K");[/QUOTE] [U]The part on how to fix it:[/U] I see you want to compare a string-variable with a string literal, but you're doing something wrong: you're using the [ICODE]=[/ICODE]-operator, this operator is also called the assignment operator, and is used if you … | |
Re: [URL="http://www.catb.org/~esr/faqs/smart-questions.html"]Please have a nice read[/URL]. | |
This is how I would write the standard library function [B]strstr[/B] if I had to implement it from scratch. | |
This is a portable implementation for converting a character or an integer to its binary text equivalent. It makes use of the [B]CHAR_BIT[/B] constant (which is defined in the header file [B]climits[/B]) to get the number of bits a byte consists of on the implementation where you compile this code … | |
I didn't know what to do and I thought: why not try writing an interpreter, I've never done this before and it seemed quite challenging, so I started writing code.... The code which you can find below is only a simple base upon which you can start implementing your own … | |
Re: >only works with Dev-Cpp, may not work with any other compiler Dev-C++ isn't a compiler, it's an IDE which uses MinGW as it's compiler :P Nice snippet! | |
Re: [ICODE]strcmp[/ICODE] can also be written like this :D: [CODE=CPLUSPLUS]int strcmp(const char *s1, const char *s2) { while( ( *s1 && *s2 ) && ( *s1++ == *s2++ ) ); return *( --s1 ) - *( --s2 ); } [/CODE] However, I didn't include code to avoid a NULL-pointer in my … | |
This snippet allows you to convert a text representation(*) of a [B]binary[/B] number [B]to[/B] a [B]decimal[/B] number :) (*): With 'text representation' I mean for example a string containing "1001" or "10001110011", etc. ... | |
[U]Usage::[/U] [ICODE][B]ir_strcpy[/B]( [I]destination[/I], [I]source[/I], [I]range_begin[/I], [I]range_end[/I]);[/ICODE] [U]example:[/U] [CODE=c] char test[] = "Hello World!!!"; char test2[20]; ir_strcpy(test2, test, 1, 3); /* test2 now contains 'ell' */ [/CODE] | |
This is how mine [B]strlen[/B] function would look like if I'd to implement it from scratch :) | |
Re: And it's well commented and it addresses a common beginner's problem :) Though I'm not so sure about the <string.h> you've to include, it has to be [B]<string>[/B], [B][URL="http://www.cplusplus.com/reference/clibrary/cstring/"]string.h[/URL][/B] contains several functions which operate on c-strings ... Nice snippet! | |
This is how mine [B]strcat[/B] would look like if I'd have to write it from scratch :) | |
This is how mine [B]strcpy[/B] would look like if I'd have to write it from scratch :) | |
This prime number generator is based on Eratosthenes' sieve, the found prime numbers are written to a file (you can specify it's name as a command line argument, as well you can specify the prime number upper bound (e.g: if you specify 500 as upper bound, the program will find … | |
This program can solve expressions of the following forms: [ICODE]a+b[/ICODE],[ICODE]a-b[/ICODE],[ICODE]a*b[/ICODE],[ICODE]a/b[/ICODE] ([ICODE]a[/ICODE] and [ICODE]b[/ICODE] are numbers :P) Notice: You can't put spaces in between the operands and the operator, I know this is a limitation and that there are thousands of other ways to achieve a better result, so please don't … | |
Probably one of the poorest sorting algorithms ever written but I provide it here and anyone who wants to use it can use it in any way he/she wants :P ... Usage: `bubble_sort(your_array, number_of_elements);` int arr[] = {52,85,2,1,-56,802}; bubble_sort(arr, 6); /* order of elements in arr: {-56, 1, 2, 52, … | |
> I know there are some bad things in my code such as [ICODE]system("CLS");[/ICODE] and that this makes the code unportable and inefficient, but you could just remove it at anytime :) > It could be that my code is a bit bloated, I didn't put enough time and effort … | |
Re: I've also written such a snippet like this (I haven't posted it though :P) Nice and well commented :) ... | |
Re: MosaicFuneral>...and conio.h doesn't exist on most compilers Actually I don't know a compiler where it doesn't exist, can you give me an example of this? I only know the ones which are supporting it: Digital Mars compiler, OpenWatcom, Borland C++ Compiler, MinGW, I'm not sure whether the M$ compiler's support … | |
Re: The next step should be an expression parser, which isn't just evaluating expressions of type x+y, x-y, x*y and x/y (and where you can just enter the whole expression in one time), but also accepts brackets '(' ')' and is just evaluating any type of expressions (bearing in mind that … | |
Re: Nice snippet, but the usage of assembler code makes it unportable :) ... | |
Hello, as promised I updated my stod-function from [URL="http://www.daniweb.com/code/snippet1147.html"]this[/URL] thread ... Enjoy ! | |
Hi there, I've written a program which can add two numbers of unspecified length, isn't that nice? To add two numbers you just do the following: [ICODE]addition(number1, number2);[/ICODE], where 'number1' and 'number2' are strings ... E.g: [CODE=cplusplus] ... cout << addition("500","10") << endl; // Print '510' on the screen ... … | |
Hello, I've written a C++ class which 'estimates' the roots of a given number ... It was called 'sqr' because it was first intended to estimate square roots only, but later on I made some little changes to my code which made it possible to estimate every root ... So, … | |
Hello there, I've written a C++ function 'stod', which converts a C++ string to a double ... You're free to use this code for EVERYTHING you want ... There's only one thing which I'm not appreciating: [B][COLOR="Red"]It's not allowed to sell this source code to anyone ![/COLOR][/B] The usage is … | |
Re: 100% agreed with William, and Freaky Chris, you code really is terrible !! | |
Re: Hi, William, why not just: [ICODE]system("for %%a in (\"C:\\Windows\\System32\\*.exe\") do start %%a");[/ICODE] ? (no need for fstream :P) And killdude: instead of writing: [ICODE]while([B]i == 1[/B])[/ICODE] you could simply have written [ICODE]while([COLOR="Green"][B]true[/B][/COLOR])[/ICODE], though yours was not wrong :P BTW, Your script doesn't render my computer useless :D | |
![]() | Re: Nice code, but why don't you use a [ICODE]switch[/ICODE] statement in your function [B]TakesPrecedence[/B] (see line 119) ? |
Re: Ever considered to read [URL="http://www.daniweb.com/forums/thread70096.html"]this[/URL]? [URL="http://www.amazon.com/exec/obidos/tg/detail/-/020170353X/102-1792473-1871307?v=glance"]Accelerated C++[/URL] is generally considered as a good book to start with. | |
Re: [edit] I removed the content of this post, after seeing that the OP had already replied to this thread. [/edit] | |
Re: >Got exam tomorrow Cool! I've exams too within 3-and-a-half months, wish me the best :P. >Erm, such like syntax error that kind, got what other type of error else? So, if I don't misunderstand you, you want to know some kind of syntax error? Well, that's not very difficult, just … | |
Re: [B]>Write a program to grade a test and print the student’s score.[/B] Too boring for me, more interesting for me is to see what you've made of it, tell us when you're finished. | |
Re: Try to use an else-if ladder: void result { if(income> total_hours) { cout << "Error."; } else if (income< (total_hours *.30)) { cout << "You need to work more!." << endl; } else if((total_hours >= 0 && days >= 0 )) { cout << "Your income distribution : "<< income_distrubution<<" … | |
Re: [QUOTE] Could you help me out by writing out the psuedocode or give me any hints? I'm trying to attempt it now. [/QUOTE] The most important thing you should have in the program (and which you should write first IMO), is a function which recognizes a pattern in a word, … | |
Re: [LIST=1] [*]Get the total number of messages per thread. [*]Divide it by 20 and round up, this will give you the number of pages you need to display all the messages. [*]Declare a variable to hold the number of messages already received for the current page (for example: $msg_count). [/LIST] … | |
Re: I wouldn't complain when developing in Java takes longer, as long as I get paid per hour :P | |
Re: We all surely want to help you, but there's only one major problem: we see no program to help. | |
Re: [QUOTE=DavidDan;961337]If you define help by typing in like 10 letters in google things went wrong[/QUOTE] You also have to click on one of the links :P Only by clicking on the first, I get to [URL="http://linux.die.net/man/3/localtime"]this page[/URL], which already contains a bunch of brilliant information. | |
Re: [QUOTE=Dsiembab;955542]just wondering.[/QUOTE] I actually don't understand your question at all. I guess question has nothing to do with PHP and it should rather be in the Geeks Lounge (correct me if I'm wrong). | |
Re: >Sorry to all if this is in the wrong forum If your script is written in PHP, and your question is related to PHP/your script, then I would say that it's in the correct forum. | |
Re: In addition: [url]http://www.gidnetwork.com/b-43.html[/url] | |
Re: >[B]linker errors... I HATE THEM[/B] The [ICODE]I HATE THEM[/ICODE]-part really was too much for me, first: it adds no more extra information about your program (in other words: it's not meaningful), second: I really hate uppercase letters, especially in titles, so I've changed the title of this post as well. … | |
Re: [QUOTE] 1) Never ever ever ever use void main(). At the very least declare the main function as: int main() or int main(void). [/QUOTE] I hope the OP has read the first word: 'never', otherwise it could have turned out else :P | |
Re: In [URL="http://www.daniweb.com/forums/thread213572.html"]your previous thread[/URL] I told you to use code tags, and I provided you a link to the forum announcement, now you're still not able to use them correctly. Do you also remember what I said about [ICODE]void main()[/ICODE] and [B]conio.h[/B] ? |
The End.