User Profile

Collapse

Profile Sidebar

Collapse
MyCGal
MyCGal
Last Activity: Nov 25 '06, 04:47 PM
Joined: Oct 6 '06
Location:
  •  
  • Time
  • Show
  • Source
Clear All
new posts

  • MyCGal
    replied to variable scope in C
    in C
    Thanks for the explaination.

    I am a little bit confused about difference between program scope and file scope.
    Program scope----
    Code:
    int i;
    main()
    {
     increment();
     increment();
    }
    
    increment()
    {
    extern i;
    i=i+1;
    printf("i= %d\n",i);
    }
    File scope----
    Code:
    static int i;
    main()
    {
    main()
    {
    ...
    See more | Go to post

    Leave a comment:


  • MyCGal
    started a topic char pointer array problem
    in C

    char pointer array problem

    Hi,

    I have this code I wrote to copy any length lines into array of pointers. The problem is after storing the individual lines into the char pointer array, the dispaly() chops off some lines while retains the others (mostly last and first line in the array). I guess there is some allocation problem but don't know where exactly.

    Please suggest.

    Code:
    int readlines(char *lineptr[], int maxlines)
    {
    ...
    See more | Go to post

  • MyCGal
    started a topic variable scope in C
    in C

    variable scope in C

    Hi,

    This is more theoretical question. When one talks about variable scope in C, there are two ways to explain it.
    1) the four types of scopes: file, function, block, function-prototype
    2) scope according to the storage class

    Which one of these is the best way to explain scope in C? Function scope refers to the label identifier. Arent the local variables in function within function scope? What do you mean...
    See more | Go to post

  • MyCGal
    replied to C structures
    in C
    Hi,

    Thanks for the code snippet. I assume that you have stored the 8 1-bit fields of the structure into char array "bits". And yes, I want to display any number of bits starting from anywhere in the bit string.
    See more | Go to post

    Leave a comment:


  • MyCGal
    replied to C structures
    in C
    Hi,

    Thanks for all your answers.

    I have more Qs. Suppose I have a struct with 8 1-bit fields. I would like to display only certain number of bits. I have a display(struct) that displays all the 8 1-bit fields. Is it possible to display only certain number of bits of this struct using display(struct a, int number_of_bits_ to_show)?
    I was thinking of converting the bits into a equivalent deceimal value and then using...
    See more | Go to post

    Leave a comment:


  • MyCGal
    started a topic C structures
    in C

    C structures

    Hi,

    I have three questions about C structures.

    First,
    How do I calculate the total number of members in the structure?
    for example,
    struct A{
    int a;
    int b;
    }
    Is it equal to sizeof(A)/sizeof(int)? But this cannot be generalized if a struct has members of different types.
    How do I do this?

    Second,
    Is it possible to define new members to struct...
    See more | Go to post
No activity results to display
Show More
Working...