User Profile

Collapse

Profile Sidebar

Collapse
DavidJones
DavidJones
Last Activity: Nov 14 '06, 03:52 AM
Joined: Nov 3 '06
Location:
  •  
  • Time
  • Show
  • Source
Clear All
new posts

  • DavidJones
    replied to question how to handle dupes
    in C
    Hi,

    In your code.

    Code:
    scores[i] =  value;
                    if (scores[i] == value) 
                    {
                    dupe = 1;
                    }
    if statement will always return true because you are assigning value to scores[i] in the previous statement. So this doesnt seems correct.

    In the code
    Code:
    if (dupe != 1)
                    {
    ...
    See more | Go to post

    Leave a comment:


  • DavidJones
    replied to static identifier
    in C
    check this link...
    http://www.phptr.com/articles/article.asp?p=3 1783&seqNum=4&r l=1


    ~David
    See more | Go to post

    Leave a comment:


  • DavidJones
    replied to global variable
    in C
    Global variables are stored in data segment of memory whereas local variables are stored in stack memory.

    ~David
    See more | Go to post

    Leave a comment:


  • Hi,

    Use modulus operator, %. It computes the remainer that results from performing integer division.

    if(number % 2 == 0) => number is even
    else number is odd.

    ~David
    See more | Go to post

    Leave a comment:


  • DavidJones
    replied to ANSI C ------ question .
    in C
    Hi,

    This function should work...

    Code:
    #include <stdio.h>
    #include <stdlib.h>
    
    //function declaration
    char *mystrcat(char *s, char *p);
    
    int main()
    {
    printf("%s",mystrcat("David","Jones"));
    }
    
    //function defination
    char *mystrcat(char *s, char *p)
    {
    static int k;
    ...
    See more | Go to post

    Leave a comment:


  • DavidJones
    replied to Splitting string into words and displaying
    in C
    Hi,

    Try this code...
    Code:
    #include <stdio.h>
    
    int main()
    {
    char str[] = "The quick brown fox jumps over the lazy dog" ;
    int i,prev,w_len;
    prev = w_len = 0;
    for(i=0;i<sizeof(str);i++)
    {
    if(str[i] == ' ' || str[i] == '\0' )
    {
    w_len = (i - prev);
    printf("\t%d\t%d\t\n", i,w_len);
    prev = i +1 ;
    }
    ...
    See more | Go to post

    Leave a comment:

No activity results to display
Show More
Working...