Forum: C 25 Days Ago |
| Replies: 4 Views: 323 Your isPrime function will return 0 for even-number and return 1 for odd-number because your loop always end at the first loop (because you always return a value at the first loop.)
Try this one... |
Forum: C Sep 21st, 2009 |
| Replies: 10 Views: 425 If I am not wrong, it is logically correct. |
Forum: C Sep 21st, 2009 |
| Replies: 10 Views: 425 You don't understand the code or the code does not work properly? It seem to work properly for me. |
Forum: C Sep 21st, 2009 |
| Replies: 7 Views: 444 For those who are lazy to search through internet here is the link: gets() vs fgets() (http://faq.cprogramming.com/cgi-bin/smartfaq.cgi?answer=1049157810&id=1043284351) |
Forum: C Aug 29th, 2009 |
| Replies: 4 Views: 361 All your code do is assigning each element of your matrix to -1 and then display them. It is no surprise at all that you did not achieve the assignment because you haven't figured or aren't willing... |
Forum: C Aug 4th, 2009 |
| Replies: 7 Views: 389 You can also use temp as char array, but you don't know how much element you need for your new string... |
Forum: C Aug 4th, 2009 |
| Replies: 7 Views: 389 Here is your code and its logical error.
int RemoveChars(char *S,char c) {
int i=0;
int spaces=0;
char temp;
for(i=0;S[i]!=0;i++) {
temp=S[i];
if(S[i]!=c) {
... |
Forum: C Aug 3rd, 2009 |
| Replies: 34 Views: 1,227 I am at my workplace right now, so I don't have any compiler to test. However, I see several things that could cause some errors.
Firstly, End=S+1;, it should be End = &S[i] + 1
Secondly, int... |
Forum: C Aug 3rd, 2009 |
| Replies: 34 Views: 1,227 Now that I don't really understand what you want for your *num. Here is what I understand before:
If I have string "Hello World", and my c is 'W'. so the *num would be 7 because letter 'W' is the... |
Forum: C Aug 3rd, 2009 |
| Replies: 34 Views: 1,227 As I have mentioned before, your code keep reset the *num to 0. To solve this problem, you need to remove the code where you reset *num:
char *Strchr(char *String, char c, int *num)
{
*num... |
Forum: C Aug 3rd, 2009 |
| Replies: 34 Views: 1,227 Sorry, I was mistaken about the increment (I was at workplace where there was no compiler to test). I'm surprised that:
*b++ and *++b get the value of the next address and also increase the... |
Forum: C Aug 2nd, 2009 |
| Replies: 34 Views: 1,227 It is difference. Let start that you string "Name". The first character of the string is 'N'. so *string++ is 'O' and next time *string++ will become 'P', 'Q', 'R', 'S'..... 'Z'....
What you want... |
Forum: C Aug 2nd, 2009 |
| Replies: 34 Views: 1,227 while(*String++), you increase your first character value by one that mean that if your first character 'A' then it will loop from 'A' to 'Z', to character 255 and then to character 0 and to 'A'... |
Forum: C Aug 2nd, 2009 |
| Replies: 34 Views: 1,227 How could *num go beyond 1 when your code does not allow it to go beyond that.
char *Strchr(char *String,char c,int *num) {
char *ptr;//whish will be ptr to first stuff we found after that... |
Forum: C Aug 2nd, 2009 |
| Replies: 18 Views: 1,107 kbhit() function is in conio.h library and conio.h is not a standard library which is not what Hiroshe want |
Forum: C Sep 18th, 2008 |
| Replies: 10 Views: 1,764 The problem that your code doesn't run properly is because you keep increase the dig without reseting it. To solve this, you can simply reset the dig to 0 in the beginning of the loop.
... |
Forum: C Sep 17th, 2008 |
| Replies: 10 Views: 1,764 If an Armstrong number is a number such that the sum of its digits raised to the third power is equal to the number itself, then I am sure that there are only 5 Armstrong numbers that does exist in... |
Forum: C Sep 17th, 2008 |
| Replies: 10 Views: 1,764 An n-digit number that is the sum of the nth powers of its digits is called an n-narcissistic number. It is also sometimes known as an Armstrong number, perfect digital invariant (Wolfram... |
Forum: C Aug 25th, 2008 |
| Replies: 10 Views: 1,296 Do you, youself, know how to convert from hex to dec and from oct to bin? If you know, then program your program to do as what you would do in real life. |
Forum: C Jan 10th, 2008 |
| Replies: 3 Views: 1,996 Logically speaking, p < p + n is always true when n is greater or equal to zero. |
Forum: C Jan 5th, 2008 |
| Replies: 7 Views: 838 You mean:
do {
.....
} while (kbhit() != ' '); |
Forum: C Dec 26th, 2007 |
| Replies: 6 Views: 1,974 (Sorry for my misunderstanding, I though 1 second = 100milliseconds. Actually, 1 second = 1000milliseconds.)
Abber: http://www.winprog.org/tutorial/animation.html , Check this tutorial to learn... |
Forum: C Dec 24th, 2007 |
| Replies: 7 Views: 1,805 The list of all functions in <unistd.h>
int access(const char *, int);
unsigned int alarm(unsigned int);
int brk(void *);
int chdir(const char *);
int ... |
Forum: C Dec 21st, 2007 |
| Replies: 15 Views: 1,713 (This is just a concept, it is not a real code)
For example: I make fishing game. There are 20 fishes and there is only one hook.
struct POS {
int x;
int y;
};
POS hook; |
Forum: C Dec 21st, 2007 |
| Replies: 15 Views: 1,713 When coding graphic game, there are two things you should know: the non-graphic part and graphic part. Non-graphic part is the bunch of variables that work in the program; Graphic part is to... |
Forum: C Dec 6th, 2007 |
| Replies: 4 Views: 809 You can using qsort() function which is come with <stdlib.h> header. Here the example of how to use this function:
#include <stdio.h>
#include <stdlib.h>
int CompareFunction(const void *p1,... |