2,384 Posted Topics
Re: [QUOTE=jralexander137;993364]I'm having trouble figuring out what exactly I'm missing in this Byte reversal method. For example is should take 0x01020304 and flip the bits to 0x04030201.[/QUOTE] So the 01 of 0x01020304 needs to move 24 bits to the right. And the 02 of 0x01020304 needs to move 8 bits to … | |
Re: [QUOTE=jralexander137;992258]Maybe its the test code that I have to use to test it is not working right? I mean for what I have is the logic correct? I'd post the test code that was given but it's like 330+lines long.[/QUOTE]Some quickie test code for my "playing along at home": [code]#include … | |
Re: [QUOTE=VuongGAD;992438]I have a homework. i don't understand it. Can you help me[/QUOTE][URL="http://www.daniweb.com/forums/announcement8-2.html"]Sure[/URL]. | |
Re: snprintf isn't C90, so it ain't quite standard C++ either. It is a common extension; I think Microsoft uses [URL="http://msdn.microsoft.com/en-us/library/2ts7cx93(VS.80).aspx"]_snprintf[/URL]. [I find it oddly comical how you've used code tags exactly the opposite of normal usage: you put non-code in code tags, and exclude putting code in code tags. :P] | |
Re: [CODE]for ( /* ... */ [COLOR="Red"][B];[/B][/COLOR] /* ... */ [COLOR="Red"][B];[/B][/COLOR] /* ... */ )[/CODE]not[CODE]for ( /* ... */ [COLOR="Green"][B],[/B][/COLOR] /* ... */ [COLOR="Green"][B],[/B][/COLOR] /* ... */ )[/CODE] | |
| |
Re: [url]http://groups.google.com/group/comp.lang.c/browse_thread/thread/3fb8ffb8dbbf3f78/d8fd4e4f8c2e4bc4#d8fd4e4f8c2e4bc4[/url] | |
Re: [QUOTE=yonghc;990123]For example: [I]int * number; char * character; float * greatnumber;[/I] These are three declarations of pointers. Each one is intended to point to a different data type, but in fact all of them are pointers and all of them will occupy the same amount of space in memory (the … | |
Re: [ICODE]remove[/ICODE] is the name of a standard library function, choose another name. | |
Re: [QUOTE=JungWoo;988068]Thank you very much for explaining, i understand more how to make header file. I have question about the end of header file, sometimes we need to put #endif, so is it necessary to put endif in header file or not?[/QUOTE] [url]http://en.wikipedia.org/wiki/Include_guard[/url] [QUOTE=DarthPJB;988163]If you are going to include your header … | |
Re: [QUOTE=bharat_h03;986554]Here type casting of pointer is required[code]int *numbers = (int *)malloc(n * sizeof(int));[/code][/QUOTE]Not in C. [url]http://faq.cprogramming.com/cgi-bin/smartfaq.cgi?answer=1047673478&id=1043284351[/url] | |
Re: This oughtta help for the compile.[code]void FillArr(student [COLOR="Red"]*[/COLOR]std,int Size) { /* ... */ void ShowArr(student [COLOR="Red"]*[/COLOR]std,int Size) { /* ... */ FillArr([COLOR="Red"]std[/COLOR],sizeof std/sizeof std[0]); ShowArr([COLOR="Red"]std[/COLOR],sizeof std/sizeof std[0]); [/code]And lots of [ICODE]->[/ICODE] to [ICODE].[/ICODE], plus [ICODE]%f[/ICODE] for floating point instead of [ICODE]%d[/ICODE]. | |
Re: [code]for (int i = 0; i < strlen (address); i++)[/code][URL="http://www.cprogramming.com/tips/showTip.php?tip=59&count=30&page=0"]Don't use strlen in a loop condition.[/URL] | |
Re: In [ICODE]getTable()[/ICODE], where do you declare [ICODE]crypt[/ICODE]? | |
Re: If you made a toy program in which you printed val in hex and then the resulting tmp in hex, do you think it would shed some light on it? [edit]Hm. Maybe not. It doesn't look like the greatest example to work with. [edit=2]...Maybe depending on what type val is. … | |
Re: [QUOTE=atch;981492]Looking through boost random library I've come across literal something like 331u. Does anyone can explain to me what this u is about? [code=c++] void seed(uint32_t value = 331u); [/code] Thank you[/QUOTE] [url]http://web.archive.org/web/20050207005628/http://dev.unicals.com/papers/c89-draft.html#unsigned-suffix[/url] [quote] The type of an integer constant is the first of the corresponding list in which its … | |
Re: [url]http://www.daniweb.com/forums/online.php[/url] [QUOTE]+ User is on your contact list[/QUOTE] ? | |
![]() | Re: [QUOTE=Dukane;962394]Is there a mobile version of DaniWeb which is better suited for viewing on PDA's and mobile phones??[/QUOTE] I mentioned it like 2 years ago. The general feeling I got was "no there isn't" and "don't expect one". |
Re: [url]http://www.parashift.com/c++-faq-lite/templates.html#faq-35.13[/url] and thereabouts. | |
Re: Since it seems to be lingering: [icode]16[/icode] decimal is [icode]10[/icode] hex, which is [icode]10000[/icode] in binary; [icode]15[/icode] decimal is [icode]0F[/icode] hex, which is [icode]1111[/icode] in binary. | |
Re: FWIW: [url]http://www.daniweb.com/forums/thread49488.html[/url] | |
Re: [code]#ifndef _EVENT_STORAGE_H_ #define _EVENT_STORAGE_H_ [COLOR="Red"]//[/COLOR]#include "eventqueue.h" [COLOR="Red"]// Do you need this here?[/COLOR] [/code] | |
Many years ago I was wandering through some SNMP code trying to port it to a Rabbit 2000. I'd guess that not many are familiar with this device -- it's an 8-bitter, and I had no operating system or dynamic memory. So there were several issues in addition to the … | |
Re: Tip: learn how to use code tags and you can leave spaces as spaces instead of replacing them with x's. And folks will appreciate it when you post your code within code tags. ;) | |
Re: [QUOTE=Miganders;979624]how come the loop not work?[/QUOTE] Code not compile? [URL="http://en.wikipedia.org/wiki/Do_while_loop#C_or_C.2B.2B"]do...while[/URL] | |
For better or worse, first impressions tend to be lasting ones. But the world does not stand still, so occasionally it may be a good idea to reevaluate things you already think you know. My earliest impression of “chat” was formed during my days as a single guy in the … | |
I am known for getting off on a tangent, or perhaps it's the onset of [URL="http://semorris.com/AAADD.htm"]AAADD[/URL]. This all started this past Christmas when I was trying to come up with gift ideas... I'd decided to try to be cool for my age and get an MP3 player for my older … | |
The following came to mind a while ago in regard to aspiring programmers who visit forums such as this. [COLOR="Silver"][I claim no credit for this, I found it somewhere on the net.][/COLOR] [QUOTE][b]The Magpie's Nest[/b] [i]By Joseph Jacobs[/i] All the birds of the air came to the magpie and asked … | |
So many of us C forum old timers have answered the same basic questions so many times that even our occasional attempts to be humorous or creative with them seem to get dull. You'd think that by the end of week one that a programmer new to C would have … | |
Re: Echoing some of this and jwenting's reply and food for thought: http://www.catb.org/~esr/faqs/hacker-howto.html#skills4 | |
This is a quick and dirty example of a hex dump utility. Not much in the way of special features -- it just dumps the contents of a hard-coded filename in hex and also shows the characters. An example that can show the basics of making your own. | |
Re: Why the silliness of having the second parameter be the wrong pointer type, in half the cases, and then casting (redundantly half the time)? | |
Re: Consider also using [INLINECODE]perror[/INLINECODE] to diagnose the problem. [code]#include <stdio.h> #include <errno.h> #include <math.h> void test(double value) { double ret; errno = 0; ret = sqrt(value); if ( errno ) { [color=blue]perror("sqrt");[/color] } else { printf("ret = %g\n", ret); } } int main() { test(-25); test(25); } /* my output … | |
This snippet uses [INLINECODE]strtod[/INLINECODE] to be a little more stringent. | |
This snippet is an example of using XOR encryption to encrypt/decrypt a file. It uses command-line input parameters as follows:[indent]argv[1] - name of input file to encrypt/decrypt argv[2] - name of output file argv[3] - crypt key[/indent]For example, an input file called "main.c" is used to create an output file … | |
In [url=http://www.daniweb.com/code/snippet259.html]Part 1[/url], the code reversed the string in place. This version uses a source and a destination string. | |
Yet another angle at this same topic. [i]See also [url=http://www.daniweb.com/code/snippet318.html]Parsing a String into Tokens Using strcspn, Part 1[/url] and [url=http://www.daniweb.com/code/snippet443.html]Parsing a String into Tokens Using strcspn, Part 2[/url].[/i] | |
This snippet is a variation of the code in [url=http://69.93.117.133/code/snippet318.html][i] Parsing a String into Tokens Using strcspn, Part 1[/i][/url]. It uses canned strings rather than reading from a file. [i]See also [url=http://www.daniweb.com/code/snippet444.html]Parsing a String into Tokens Using strcspn, Part 3[/url].[/i] | |
How might I write an implementation in C of a case-insensitive version of the standard library function [inlinecode]strcmp[/inlinecode]? Here's how I might. This this is often available as a nonstandard function that may be called [inlinecode]stricmp[/inlinecode], [inlinecode]_stricmp[/inlinecode], [inlinecode]strcmpi[/inlinecode], or [inlinecode]strcasecmp[/inlinecode]. [i]See also [url=http://69.93.117.133/code/misc.php?action=edit&codeid=316]Strings: Comparing[/url].[/i] | |
Break down an amount into units of dollars and cents. | |
How might I write an implementation in C of the standard library function [inlinecode]strcat[/inlinecode]? Here's how I might. | |
If the user tries to put 80 characters in a 20-character buffer, you may have issues. This snippet shows one way to cap the input and discard excess input. [i]See also [url=http://www.daniweb.com/code/snippet280.html]Safe Version of gets()[/url] and [url=http://www.daniweb.com/code/snippet278.html]Read a Line of Text from the User[/url].[/i] | |
This snippet shows one way to calculate the number of days since a given date until present time. Note that this code will not work for dates outside of the current epoch, which typically begins on January 1, 1970. | |
Some issues, such as leading whitespace and trailing characters that cannot be part of a number, were not handled in [url=http://www.daniweb.com/code/snippet357.html]Read a Floating-Point Value from the User, Part 1[/url]. Here such issues receive lip service. [I]See also [url=http://www.daniweb.com/code/snippet597.html]Read a Floating-Point Value from the User, Part 3[/url][/I]. | |
Obtaining user input can be done in many surprisingly different ways. This code is somewhere in the middle: safer than [inlinecode]scanf("%lf", &n)[/inlinecode], but not bulletproof. It is meant to be a simple but relatively safe demonstration. Note also that there would be slight differences for using [inlinecode]float[/inlinecode] instead of [inlinecode]double[/inlinecode]. … | |
This snippet asks the user to fill in a structure and saves each record to the file. It uses append mode to add each new record to the end of the file. After all input is taken, it prints out the contents of the file. [i]Disclaimer: [font=courier new]fread[/font] and [font=courier … | |
Some issues, such as leading whitespace and trailing characters that cannot be part of a number, were not handled in [url=http://www.daniweb.com/code/showsnippet.php?codeid=266]Read an Integer from the User, Part 1[/url]. Here such issues receive lip service. | |
This snippet shows one way to count the number of lines in a file. It will count the last line of a file even if the last line does not end in a newline. Usage: [code]C:\>linecnt linecnt.c lines = 32[/code] | |
How might I write an implementation in C of the standard library function [inlinecode]strcmp[/inlinecode]? Here's how I might. [i]See also [url=http://69.93.117.133/code/snippet440.html] Strings: Comparing, Case-Insensitive[/url].[/i] |
The End.