User Profile

Collapse

Profile Sidebar

Collapse
andersod
andersod
Last Activity: Dec 14 '07, 05:32 PM
Joined: Mar 8 '07
Location:
  •  
  • Time
  • Show
  • Source
Clear All
new posts

  • andersod
    replied to Analyzing a program
    in C
    hi,
    It seems that there are a number of errors placed in the code to help you to understand what your instructor is trying to teach you. If you are not sure of what you are doing, try doing the following.

    1. place comments arround the class object that is being called.
    2. In main, place a comment arround the instantiation of the object in step 1.
    3. compile the code and fix the errors.
    4. run the...
    See more | Go to post

    Leave a comment:


  • Hi,
    try these changes to your code.

    #include <stdio.h>
    int main() {
    FILE *fi;
    float val, maximum = 0, minimum = 0, sum=0.0;
    int i, n=10;
    if ( (fi=fopen("rain fall.dat","r")) == NULL ) {
    fprintf(stderr, "ERROR opening file!\n"); return 1; }
    fscanf(fi,"%f", &val);

    while ( (val >= 0 ) &&...
    See more | Go to post

    Leave a comment:


  • andersod
    replied to Help with tokenizing
    in C
    hi,
    try the following:

    change if (isdigit(tokena rray[1]) != 0)
    to if (isdigit(*token array[1]) != 0)

    regards,
    andersod
    See more | Go to post

    Leave a comment:


  • andersod
    replied to delay second output for 3 secs
    in C
    hi,
    try

    #define __cpp_stdc
    #include <stdio.h>
    #include <unistd.h>

    void SLEEP(int x)
    {
    sleep(x);
    }
    int main() {
    printf("line 1\n");
    fflush(stdout);
    SLEEP(10);
    printf("line 1\n");
    fflush(stdout);
    return(0);
    }
    See more | Go to post

    Leave a comment:


  • andersod
    replied to AIX xlC compiler v8.0 auto_ptr
    in C
    Hi,
    I get the same message except that it says "string" instead of "String".
    I opened a ticket with IBM and they are looking into it. I will add that information here after it is resolved.

    Thanks.
    See more | Go to post

    Leave a comment:


  • andersod
    replied to Convert array element
    in C
    hi,,
    you could also do the following:

    char ch[]={'A','B','C'};
    int i;
    for(i=0; i<3;i++) {
    int val = (int)ch[i];
    printf("charact er %c integer value %d\n", ch[i], val);
    }
    desmond
    See more | Go to post

    Leave a comment:


  • andersod
    replied to Convert array element
    in C
    hi,
    You said in you initial statement that the language is c. I assumed you wanted c version.

    Anyway, it does not matter. "void *" takes anything. This allows you to store and retrieve any data type that you want by type casting it when storing, retrieving, allocating,and distroying the memory area. "void *" gives you more control of you datatypes.
    It also works perfectly in c++. I am also...
    See more | Go to post

    Leave a comment:


  • andersod
    replied to Convert array element
    in C
    Hi,
    Try defining the array variable as type void, then typecast it to the different types.

    ex.
    #include <stdio.h>
    #include <stdlib.h>
    int main(){
    void *x = NULL;
    x = (int *)1;
    printf("the value is %d\n",(int *)x);
    x = (char *)'A';
    printf("the character is %c\n",(char*)x) ;
    }

    result:
    the value...
    See more | Go to post

    Leave a comment:


  • andersod
    started a topic AIX xlC compiler v8.0 auto_ptr
    in C

    AIX xlC compiler v8.0 auto_ptr

    Hi,
    I am migrating to an AIX platform and I have the following sample code.

    #include <stdio.h>
    #include <string>
    #include <memory>
    int main() {
    auto_ptr<String > pl = new String;
    pl->assign((char *)"Hello World");
    printf("%s\n",( char *)pl->c_str());
    }


    I tried compiling using the following:...
    See more | Go to post
No activity results to display
Show More
Working...