Search Results

Showing results 1 to 40 of 69
Search took 0.01 seconds.
Search: Posts Made By: invisal ; Forum: C and child forums
Forum: C Nov 7th, 2009
Replies: 4
Views: 379
Posted By invisal
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: 437
Posted By invisal
If I am not wrong, it is logically correct.
Forum: C Sep 21st, 2009
Replies: 10
Views: 437
Posted By invisal
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: 460
Posted By invisal
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 Sep 18th, 2009
Replies: 3
Views: 694
Posted By invisal
We don't do homework for you.
Forum: C Sep 14th, 2009
Replies: 7
Views: 877
Posted By invisal
I am greatly disappointed.
Forum: C Aug 30th, 2009
Replies: 2
Views: 389
Posted By invisal
I have finally found the solution to my problem, so I am going to share it to anyone who interest the same thing as what I am



int main()
{
// allocate 8 bytes for storing machine code...
Forum: C Aug 30th, 2009
Replies: 19
Views: 1,024
Posted By invisal
Don't mess with Narue. Look at her avatar, you will get some idea :sweat:
Forum: C Aug 29th, 2009
Replies: 4
Solved: please help
Views: 373
Posted By invisal
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 29th, 2009
Replies: 2
Views: 389
Posted By invisal
Recently, I have wonder how to execute machine code instruction from memory in C/C++. I am aware of data execution protection. Anyway, I have this piece of code:


int main()
{
// allocate 2...
Forum: C Aug 22nd, 2009
Replies: 11
Views: 1,141
Posted By invisal
Ouch! Didn't know this trick before
Forum: C Aug 22nd, 2009
Replies: 11
Views: 1,141
Posted By invisal
Took me 5 minutes to indent your code


/*This program removes duplicates from a sorted array of integers*/

#include <stdio.h>
#include "genlib.h"
#include "simpio.h"
#include "strlib.h"...
Forum: C Aug 6th, 2009
Replies: 18
Views: 596
Posted By invisal
To be honest, it is hard to read your code without know the clear purpose of what your function intent to do. It would be easy if you tell us what will your function return, what each parameters do,...
Forum: C Aug 5th, 2009
Replies: 18
Views: 596
Posted By invisal
1. Why create this function when you can simply compare two characters with operator ==.

int Check_Characters(char s1,char s2) {
if(s1==s2)
return 1;
return 0;
}
Forum: C Aug 5th, 2009
Replies: 3
Views: 298
Posted By invisal
Or another faster way is using modulus operator.


Pseudo code:
For i = 0 To 3
Print i % 2
Next i

Result:
0 1 0 1
Forum: C Aug 4th, 2009
Replies: 7
Views: 397
Posted By invisal
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: 397
Posted By invisal
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,278
Posted By invisal
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,278
Posted By invisal
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,278
Posted By invisal
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,278
Posted By invisal
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,278
Posted By invisal
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,278
Posted By invisal
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,278
Posted By invisal
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,149
Posted By invisal
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,813
Posted By invisal
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,813
Posted By invisal
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,813
Posted By invisal
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,312
Posted By invisal
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 Mar 10th, 2008
Replies: 21
Views: 10,120
Posted By invisal
How about this array [2, 4, 1, 5, 6]
so the maximun of subset sum is 2 + 4 + 1 + 5 + 6 = 17?
Forum: C Mar 9th, 2008
Replies: 21
Views: 10,120
Posted By invisal
Sorry, but I still don't understand what is "subset with maximum sum". Can anyone explain or give me more examples?
Forum: C Feb 16th, 2008
Replies: 17
Views: 4,542
Posted By invisal
gerard4143, you're still using operator (-)
Forum: C Feb 14th, 2008
Replies: 17
Views: 4,542
Posted By invisal
Forum: C Feb 14th, 2008
Replies: 17
Views: 4,542
Posted By invisal
Not a good way :( but it works fine.


int sum(int num1, int num2)
{
int total, temp, temptotal;
total = num1 ^ num2;
for(temp = num1 & num2; temp != 0; temp = temptotal & temp) {...
Forum: C Feb 13th, 2008
Replies: 5
Views: 4,667
Posted By invisal
Firstly, base8 = y*8^n does not have semi-colon at the end of the statement. Secondly, ^ is not a power operator. I think you are confusing with Visual Basic. Moreover, x/10 = x; and x %10 =y; are...
Forum: C Feb 9th, 2008
Replies: 20
Views: 3,269
Posted By invisal
Yes, but the topic say divisible by 2 and 3.
Forum: C Feb 9th, 2008
Replies: 20
Views: 3,269
Posted By invisal
If one number divisible by 2 and 3, it is also divisible by 6.

for(i = 1; i <= 100; i++) {
if (i % 6)
// this condition is true whenever i is not divisible by number 2 and 3.
}
Forum: C Feb 6th, 2008
Replies: 7
Views: 953
Posted By invisal
Sorry. Without much thinking, I jumped to answer this question.
Forum: C Feb 6th, 2008
Replies: 7
Views: 953
Posted By invisal
Alternative way from Narue:


// input your num here.
for (temp = num; temp > 9; temp /= 10)
printf("%c", '0' + (temp % 10));
Forum: C Feb 2nd, 2008
Replies: 2
Views: 2,931
Posted By invisal
I am not sure what you're looking for, maybe you mean continue;?
Showing results 1 to 40 of 69

 


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

©2003 - 2009 DaniWeb® LLC