Search Results

Showing results 1 to 21 of 21
Search took 0.01 seconds.
Search: Posts Made By: Ptolemy ; Forum: C and child forums
Forum: C Nov 2nd, 2007
Replies: 19
Views: 13,489
Posted By Ptolemy
>you are assuming something about implementation dependent architecture
No, you're assuming that 50 is meaningful in telling you the length of the source string. The two examples are not equivalent...
Forum: C Nov 1st, 2007
Replies: 1
Views: 1,684
Posted By Ptolemy
>wen i use larger values say 245323465 etc. the sorted matrix returned garbage values.. y s that?
Garbage values usually mean that you either didn't initialize the value in the first place, or you...
Forum: C Nov 1st, 2007
Replies: 19
Views: 13,489
Posted By Ptolemy
>i'm probably doing something basically wrong in the fubction maybe.
Are you passing any arguments to your program? If not, argv[1] isn't guaranteed to be there, and if it is, it's pretty much sure...
Forum: C Oct 31st, 2007
Replies: 7
Views: 9,738
Posted By Ptolemy
>I feel like a dumbass for writing such bad code
It's not that bad... :-/
Forum: C Oct 31st, 2007
Replies: 7
Views: 9,738
Posted By Ptolemy
>printf(head->data);
printf takes a string as the first argument, not an integer. You probably just forgot to add the format string, which would make the line look like this:

printf("%d\n",...
Forum: C Oct 25th, 2007
Replies: 3
Views: 2,951
Posted By Ptolemy
>try using %s in the scanf's
No, don't. At least don't until you know how to safely use %s and change the input variables to arrays. Otherwise you'll invoke undefined behavior and create security...
Forum: C Oct 25th, 2007
Replies: 1
Views: 545
Posted By Ptolemy
It's better to put the code directly in your post if it's short. The problem is that floating-point values aren't always exact, so you can't reliably test for equality. The usual fix for your problem...
Forum: C Oct 25th, 2007
Replies: 2
Views: 1,066
Posted By Ptolemy
If it's urgent, won't it be faster to write it yourself than wait for someone to send you something that may or may not work like you want? Also, if it's urgent, it's probably homework, and using...
Forum: C Oct 25th, 2007
Replies: 4
Views: 1,297
Posted By Ptolemy
I'd start with the fact that functions can't be nested inside of each other in C. You're also calling letter before it's declared.
Forum: C Oct 23rd, 2007
Replies: 7
Views: 4,440
Posted By Ptolemy
Just so we're clear. :)


Sloppy code is sloppy code, regardless of whether it's spawned from negligence or ignorance.


That's a safe bet. ;)


I guess I can't argue with carefully...
Forum: C Oct 23rd, 2007
Replies: 7
Views: 4,440
Posted By Ptolemy
I didn't realize you were the one who wrote those articles. :)


%s isn't the only way to read strings, but I'll take your point as talking only about %s without a field width.


So is printf...
Forum: C Oct 23rd, 2007
Replies: 7
Views: 4,440
Posted By Ptolemy
>I disagree. You have to have all kinds of special code to get scanf() to work properly.
Only if you aren't using scanf for what it was designed in the first place. When you have to write workaround...
Forum: C Oct 22nd, 2007
Replies: 3
Views: 582
Posted By Ptolemy
There's no way to print a binary value directly in C. You have to break the value up into bits and basically do it all manually:

#include <stdio.h>

int main ( void )
{
int x;

printf (...
Forum: C Oct 22nd, 2007
Replies: 12
Views: 1,980
Posted By Ptolemy
>Haven't you figure out yet why you should avoid using scanf?
I don't think you should avoid scanf. I think you should learn how it works so that you can use it intelligently.

>Reading an integer...
Forum: C Oct 21st, 2007
Replies: 12
Views: 1,980
Posted By Ptolemy
Something like this, I suppose:

int GetIntInput(int min, int max)
{
printf("Please enter an integer:\n");

if (scanf ("%i", &val) != 1)
{
printf ( "Invalid input! Please enter your...
Forum: C Oct 21st, 2007
Replies: 7
Views: 1,955
Posted By Ptolemy
>Where's the case insensitive in the original OP my_strcmp?

temp1 = my_strlwr(str1);
temp2 = my_strlwr(str2);
Forum: C Oct 21st, 2007
Replies: 12
Views: 1,980
Posted By Ptolemy
If you're using scanf, you can just test the return value. It returns the number of items that were successfully converted:

int x;

if ( scanf ( "%d", &x ) != 1 )
fprintf ( stderr, "Invalid...
Forum: C Oct 21st, 2007
Replies: 7
Views: 1,955
Posted By Ptolemy
>You are making MY_STRING the same that my_string.
What's my_string?

>And that's not what strcmp() does.
It's exactly what strcmp does, with the exception that my_strcmp is case insensitive. I...
Forum: C Oct 21st, 2007
Replies: 6
Views: 1,586
Posted By Ptolemy
I see that your function is empty. What have you tried so far?
Forum: C Oct 21st, 2007
Replies: 7
Views: 1,955
Posted By Ptolemy
>I thought by not using the input pointers directly can prevent all the possibilities of modifying them.
Not quite:

#include <stdio.h>

void foo ( int *p )
{
int *temp = p;

*temp =...
Forum: C Oct 21st, 2007
Replies: 7
Views: 1,955
Posted By Ptolemy
>int my_strcmp (char *str1, char *str2)
When I'm comparing strings, I expect them to remain unchanged. So you should make str1 and str2 pointers to const char.

>temp1 = my_strlwr(str1);
>temp2 =...
Showing results 1 to 21 of 21

 


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

©2003 - 2009 DaniWeb® LLC