Search Results

Showing results 1 to 40 of 85
Search took 0.03 seconds.
Search: Posts Made By: Dave Sinkula ; Forum: C and child forums
Forum: C 3 Days Ago
Replies: 14
Views: 327
Posted By Dave Sinkula
Bleh. I need to call it a night and leave better advice to others.
#include <stdio.h>
#include <string.h>

#define NAME_LEN 25
#define OWNER_LEN 25
#define STATUS_LEN 4
#define DATE_LEN 11...
Forum: C 4 Days Ago
Replies: 7
Views: 201
Posted By Dave Sinkula
Dunno.
#include <stdio.h>
#include <stdlib.h>

/**
* A simple line-counter. (Has issues with special cases.)
* @param file pointer to a file stream
* @return the number of lines in the...
Forum: C 12 Days Ago
Replies: 7
Views: 350
Posted By Dave Sinkula
Try printing the bytes in the buffer rather than printing the buffer as a string (especially when you are not treating buffer as a string).
Forum: C 13 Days Ago
Replies: 1
Views: 199
Posted By Dave Sinkula
Expected input and output would be helpful. Providing a small snippet of a simple test, minimal but complete and compilable, would too.

"This code doesn't do what I want (and I'm not going to tell...
Forum: C 14 Days Ago
Replies: 14
Views: 658
Posted By Dave Sinkula
*sigh*

Of course it is. ALL structures of the structures in the first example are populated at compile time. A particular one isn't "selected" in the if tree.
Forum: C 30 Days Ago
Replies: 2
Views: 266
Posted By Dave Sinkula
fmod (http://web.archive.org/web/20050207005628/http://dev.unicals.com/papers/c89-draft.html#4.5.6.4)
Forum: C Oct 26th, 2009
Replies: 2
Views: 197
Posted By Dave Sinkula
Do you really think this is enough information for any kind of an answer?
Forum: C Oct 25th, 2009
Replies: 6
\n
Views: 205
Posted By Dave Sinkula
http://c-faq.com/stdio/scanfhang.html
Forum: C Oct 19th, 2009
Replies: 6
Views: 270
Posted By Dave Sinkula
Go back and look at that link I'd posted, I'm sure it mentions code tags at some point.

Do you know which language you are using? You seem to have merrily mixed C and C++ (perhaps "borrowing" code...
Forum: C Oct 4th, 2009
Replies: 8
Views: 65,583
Posted By Dave Sinkula
Why not post this failing example so I know what you mean?

Brought up recently by tux4life and explained by Narue (http://www.daniweb.com/forums/post956935.html#post956935), the fgets/sscanf code...
Forum: C Oct 1st, 2009
Replies: 5
Views: 514
Posted By Dave Sinkula
Danke. I was thinking something a little more canned:
#include <stdio.h>
#include <limits.h>

/* Check if s1 and s2 are anagrams of each other */
int isAnagram(const char *s1, const char *s2)
{...
Forum: C Sep 30th, 2009
Replies: 11
Views: 634
Posted By Dave Sinkula
%d -> %02d
#include <stdio.h>

int main(void)
{
int h = 1, m = 1, s = 1;
printf("%02d:%02d:%02d", h, m, s);
return 0;
}
Forum: C Sep 26th, 2009
Replies: 26
Views: 986
Posted By Dave Sinkula
I'll sidestep the why for a moment and mention that strlen is a reserved identifier and simply should not be used for your own function name.

[edit]C Reserved Identifiers...
Forum: C Sep 21st, 2009
Replies: 17
Views: 1,464
Posted By Dave Sinkula
#include <stdio.h>
#include <limits.h>

int main()
{
int x;
unsigned y;

printf("INT_MAX = %d\n", INT_MAX);
if ( 0xFFFF < INT_MAX )
Forum: C Sep 17th, 2009
Replies: 2
Views: 408
Posted By Dave Sinkula
remove is the name of a standard library function, choose another name.
Forum: C Sep 7th, 2009
Replies: 9
Views: 412
Posted By Dave Sinkula
FWIW: http://www.daniweb.com/forums/thread49488.html
Forum: C Aug 27th, 2009
Replies: 8
Views: 394
Posted By Dave Sinkula
I'd say your understanding of char *a needs a little work.
I would say that a is a pointer that points to an unnamed array of constant characters.

Maybe these will help:...
Forum: C Aug 19th, 2009
Replies: 15
Views: 492
Posted By Dave Sinkula
Danger Will Robinson! That's not a compiler, it's an unfinished toy.

I'd recommend finding a different compiler, yes.
Forum: C Aug 17th, 2009
Replies: 1
Views: 222
Posted By Dave Sinkula
Seems more like C++. Do you have a minimal compileable snippet that produces the results you see?
#include <stdio.h>

struct f_c_8
{
union
{
float f;
unsigned char c[8];
...
Forum: C Aug 12th, 2009
Replies: 22
Views: 1,076
Posted By Dave Sinkula
Read the user input as a string, validate the string according to the specific details for dollar amount entry. Such as, begins with dollar sign, is followed by nothing but digits until a possible...
Forum: C Aug 7th, 2009
Replies: 12
Solved: GOTO command
Views: 725
Posted By Dave Sinkula
No.
Try to think about the real loop control and a better loop construct will come to mind.
---
http://en.wikipedia.org/wiki/Goto#Criticism_of_goto_usage
Forum: C Aug 2nd, 2009
Replies: 18
Views: 1,107
Posted By Dave Sinkula
As you saw in the link...

The standard behavior is to do nothing in particular for any keypress, save the return key.
Forum: C Jul 31st, 2009
Replies: 16
Views: 757
Posted By Dave Sinkula
So loop.
double *powerArgs(int *a, int *b)
{
static double result;
int i;
for ( i = 0, result = 1; i < *b; ++i )
{
result *= *a;
}
return &result;
Forum: C Jul 30th, 2009
Replies: 16
Views: 757
Posted By Dave Sinkula
pow (http://web.archive.org/web/20050207005628/http://dev.unicals.com/papers/c89-draft.html#4.5.5.1)?
Forum: C Jul 29th, 2009
Replies: 5
Views: 227
Posted By Dave Sinkula
A brief note on signals and calling standard library functions:
http://groups.google.com/group/comp.lang.c/browse_thread/thread/00d5082d648b2437/a4d67511412817da#a4d67511412817da

[edit]Doing some...
Forum: C Jul 26th, 2009
Replies: 7
Solved: silly
Views: 240
Posted By Dave Sinkula
http://c-faq.com/expr/ieqiplusplus.html
Forum: C Jul 9th, 2009
Replies: 11
Views: 503
Posted By Dave Sinkula
I don't know if I read you correctly. My hint towards a suggested replacement would be:
char **arrayToReturn = malloc(height * sizeof *arrayToReturn);[edit]This being your original:
char**...
Forum: C Jul 8th, 2009
Replies: 6
Views: 343
Posted By Dave Sinkula
#include <stdio.h>

int main(void)
{
int b[10][5] ;
int (*q)[10][5] = &b ;
printf("%p - %p = %d chars\n", q+1, q, (char*)(q+1) - (char*)q);
printf("%p - %p = %d ints\n", q+1, q,...
Forum: C Jun 19th, 2009
Replies: 24
Views: 1,430
Posted By Dave Sinkula
man difftime (http://clusty.com/search?query=man%20difftime)
[edit]This (http://www.daniweb.com/code/snippet367.html) has similarities to the original topic.

Slight nitpick:
A time_t is not...
Forum: C Jun 16th, 2009
Replies: 16
Views: 1,092
Posted By Dave Sinkula
They are the same for printf, but they are different for scanf. Both are used for integers, though. %i may read the input as hexadecimal or octal as well as decimal.
Forum: C Jun 5th, 2009
Replies: 1
Views: 566
Posted By Dave Sinkula
http://c-faq.com/stdio/scanfhang.html...
Forum: C Jun 2nd, 2009
Replies: 22
Solved: help me
Views: 931
Posted By Dave Sinkula
That's the point. ;)
Forum: C Jun 2nd, 2009
Replies: 22
Solved: help me
Views: 931
Posted By Dave Sinkula
#include <stdio.h>

void showcolor(int color)
{
if ( color && 1 ) puts("violet");
if ( color && 2 ) puts("indigo");
if ( color && 4 ) puts("blue");
if ( color && 8 )...
Forum: C May 28th, 2009
Replies: 23
Views: 937
Posted By Dave Sinkula
http://projecteuler.net/index.php?section=problems
Forum: C May 22nd, 2009
Replies: 15
Solved: Using sprintf
Views: 1,176
Posted By Dave Sinkula
sscanf (http://www.daniweb.com/code/snippet353.html) or strtoul (http://www.daniweb.com/code/snippet441.html)?
#include <stdio.h>

int main()
{
const char representation[] = "1234";
int...
Forum: C May 20th, 2009
Replies: 18
Views: 813
Posted By Dave Sinkula
Writing to read-only memory is undefined behavior. Maybe take another swing at this one.
Forum: C May 15th, 2009
Replies: 5
Views: 554
Posted By Dave Sinkula
It is often prudent to test around the edges.
#include <stdio.h>
#include <stdlib.h>
#include <limits.h>

int cmp1(int a, int b)
{
return a == b ? 0 : a < b ? -1 : 1;
}
Forum: C May 7th, 2009
Replies: 9
Views: 370
Posted By Dave Sinkula
NULL, 0, \0 and nul (http://faq.cprogramming.com/cgi-bin/smartfaq.cgi?answer=1047589067&id=1043284376)
Forum: C Apr 20th, 2009
Replies: 18
Views: 805
Posted By Dave Sinkula
Sometimes I choose sscanf. Ballpark?
#include <stdio.h>
#include <ctype.h>

void parse_title(const char *text)
{
char word[128];

/* skip leading whitespace, if any */
while (...
Forum: C Oct 10th, 2008
Replies: 7
Views: 764
Posted By Dave Sinkula
Consider also sscanf for parsing the source string.
#include <stdio.h>

int main()
{
const char text[] = "7/23/76";
int month, day, year;
if ( sscanf(text, "%d/%d/%d", &month, &day,...
Showing results 1 to 40 of 85

 


About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC