2,384 Posted Topics

Member Avatar for jralexander137

[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 …

Member Avatar for codeguru_2009
0
241
Member Avatar for jralexander137

[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 …

Member Avatar for jralexander137
0
913
Member Avatar for VuongGAD

[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].

Member Avatar for sfuo
0
113
Member Avatar for iceshells

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]

Member Avatar for Dave Sinkula
0
447
Member Avatar for buriza

[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]

Member Avatar for Sky Diploma
0
93
Member Avatar for AirGear
Member Avatar for KonkaNok

[url]http://groups.google.com/group/comp.lang.c/browse_thread/thread/3fb8ffb8dbbf3f78/d8fd4e4f8c2e4bc4#d8fd4e4f8c2e4bc4[/url]

Member Avatar for KonkaNok
0
148
Member Avatar for KIEX
Member Avatar for yonghc

[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 …

Member Avatar for yonghc
0
414
Member Avatar for TGeorge824

[ICODE]remove[/ICODE] is the name of a standard library function, choose another name.

Member Avatar for Dave Sinkula
0
925
Member Avatar for JungWoo

[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 …

Member Avatar for Dave Sinkula
0
141
Member Avatar for jralexander137

[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]

Member Avatar for Salem
0
170
Member Avatar for MrNoob

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].

Member Avatar for MrNoob
0
152
Member Avatar for helpme123456789

[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]

Member Avatar for VernonDozier
0
227
Member Avatar for cbreeze
Member Avatar for namehere05
0
212
Member Avatar for rmeltg

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. …

Member Avatar for rmeltg
0
110
Member Avatar for atch

[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 …

Member Avatar for Dave Sinkula
0
159
Member Avatar for lllllIllIlllI

[url]http://www.daniweb.com/forums/online.php[/url] [QUOTE]+ User is on your contact list[/QUOTE] ?

Member Avatar for lllllIllIlllI
0
91
Member Avatar for Dukane

[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".

Member Avatar for Dani
0
121
Member Avatar for 42Wired

[url]http://www.parashift.com/c++-faq-lite/templates.html#faq-35.13[/url] and thereabouts.

Member Avatar for 42Wired
0
131
Member Avatar for D.JOHN

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.

Member Avatar for D.JOHN
0
703
Member Avatar for priyairani00
Member Avatar for priyairani00
0
89
Member Avatar for F2guy

[code]#ifndef _EVENT_STORAGE_H_ #define _EVENT_STORAGE_H_ [COLOR="Red"]//[/COLOR]#include "eventqueue.h" [COLOR="Red"]// Do you need this here?[/COLOR] [/code]

Member Avatar for F2guy
0
261
Member Avatar for Dave Sinkula

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 …

Member Avatar for Dave Sinkula
0
167
Member Avatar for kyumi419

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. ;)

Member Avatar for kyumi419
0
143
Member Avatar for Miganders

[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]

Member Avatar for Miganders
0
109
Member Avatar for Dave Sinkula

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 …

Member Avatar for joshSCH
0
198
Member Avatar for Dave Sinkula

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 …

0
61
Member Avatar for Dave Sinkula

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 …

Member Avatar for Aia
0
196
Member Avatar for Dave Sinkula

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 …

Member Avatar for safinsafi21
0
259
Member Avatar for tgreer

Echoing some of this and jwenting's reply and food for thought: http://www.catb.org/~esr/faqs/hacker-howto.html#skills4

Member Avatar for Scottg1989
0
333
Member Avatar for Dave Sinkula

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.

0
233
Member Avatar for serkan sendur

Why the silliness of having the second parameter be the wrong pointer type, in half the cases, and then casting (redundantly half the time)?

Member Avatar for Dave Sinkula
0
235
Member Avatar for SpS

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 …

Member Avatar for Dave Sinkula
0
340
Member Avatar for Dave Sinkula
Member Avatar for bemboysms
0
249
Member Avatar for Dave Sinkula

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 …

Member Avatar for vonqi
0
338
Member Avatar for Dave Sinkula

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.

0
137
Member Avatar for Dave Sinkula

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]

0
726
Member Avatar for Dave Sinkula

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]

0
747
Member Avatar for Dave Sinkula

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]

0
355
Member Avatar for Dave Sinkula
0
150
Member Avatar for Dave Sinkula

How might I write an implementation in C of the standard library function [inlinecode]strcat[/inlinecode]? Here's how I might.

0
292
Member Avatar for Dave Sinkula

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]

0
324
Member Avatar for Dave Sinkula

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.

0
763
Member Avatar for Dave Sinkula

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].

0
438
Member Avatar for Dave Sinkula

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]. …

0
211
Member Avatar for Dave Sinkula

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 …

1
491
Member Avatar for Dave Sinkula

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.

Member Avatar for drxs33
1
471
Member Avatar for Dave Sinkula

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]

0
171
Member Avatar for Dave Sinkula

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]

0
1K

The End.