User Profile

Collapse

Profile Sidebar

Collapse
rahul sinha
rahul sinha
Last Activity: Oct 8 '12, 01:58 PM
Joined: Jan 21 '11
Location:
  •  
  • Time
  • Show
  • Source
Clear All
new posts

  • Unable to resolve an expected primary expression error

    Code:
    void myglOrtho(GLfloat left,GLfloat right,GLfloat bottom,GLfloat top,GLfloat far,GLfloat near)
    {
            GLfloat a,b,c,d,e,f;
            
              a=left-right; 
              b=left+right; 
              c=bottom-top;
              d=bottom+top; 
              e=far-near;
              f=far+near;
              
              
              
         
         GLfloat m[] = { (2.0f/-a), 0.0f,
    ...
    See more | Go to post
    Last edited by Rabbit; Oct 8 '12, 03:18 PM. Reason: Please use code tags when posting code.

  • supppose i have defined a variable in some other file say external.c but i have not included that file in my present file test.c...and if i make an extern declaration of the same variable..then will i be able to access it...
    See more | Go to post

    Leave a comment:


  • rahul sinha
    replied to Can void pointers be dereferenced?
    in C
    hey donbock i got it now that compiler doesn't know the type of variable to which a void pointer is pointing..but what i thought that,since void can point to any variable type so if we assign a void pointer to any pointer of some other type like :
    {
    void *p;
    int *p1;
    *p1=5;
    p=p1;
    /*now p points to p1(an integer type))*/
    /*so*/
    printf("%d",*p) ;/*will this statement work*/
    }...
    See more | Go to post

    Leave a comment:


  • rahul sinha
    started a topic Can void pointers be dereferenced?
    in C

    Can void pointers be dereferenced?

    Code:
    #include<stdio.h>
    #include<conio.h>
    
    void main()
    
    {
    void *ptr;
    char *a='A';
    char *b="TAN";
    int i=50;
    ptr=a;
    ptr=(char*)malloc(sizeof(a));
    printf("%c",*ptr);
    ptr=i;
    ptr=(int*)malloc(sizeof(i));
    printf("%d",++(*ptr));
    ptr=b;
    ptr=(char*)malloc(sizeof(b));
    printf("%c",++(*ptr));
    getch();
    ...
    See more | Go to post
    Last edited by Niheel; Jan 27 '11, 05:21 AM. Reason: Use proper grammar and punctuation. Your posts are hard to read. If we have to edit any more your account will be suspended.

  • okay,no problem,,,i will keep it in notice from next time.......
    See more | Go to post

    Leave a comment:


  • thank you sir....i am really grateful to you for solving my problems with such ease...can i have your id..i would like to learn more from you..(only if thats okay with you)....
    See more | Go to post
    Last edited by Dormilich; Jan 26 '11, 12:28 PM. Reason: removed email address

    Leave a comment:


  • okay i got that how to declare....but if i am defining a variable in one file say test.c and i want it to be used in other file..then in test.c,do i have to prefix extern before variable definition,,, like extern int a=20; ...and if not then howcome in any file making an extern declaration of varibale a will help me access the variable -a- of file test.c.........
    See more | Go to post

    Leave a comment:


  • How is an external variable is accessed from one file to another?

    Can someone demonstrate how an external variable is accessed from one file to another? Also how do we use it when we have already defined the external variable in the source file?
    See more | Go to post
    Last edited by Niheel; Jan 26 '11, 01:33 AM. Reason: Please use proper grammar and spelling. Making your question easily readable to everyone is the quickest way to get an answer.

  • ok,that means with characters ctrl+z has ascii value 26 and when
    provided alone getchar returns unsigned form of -1...(on this
    compiler)...but enter is also there in the buffer then why does it not
    print enter's ascii value which is 10.....
    See more | Go to post

    Leave a comment:


  • what if we suffix the input string with ctrl+z on a windows os(an EOF character).and then press enter....in that case getchar() should read eof as well and comeout of the loop no...
    See more | Go to post

    Leave a comment:


  • hey people, i wanted to ask,if i type a line and then press enter,how come getchar() is still able to read all the characters of a line..if it only reads a character after pressing enter....It appears as if its reading line by line ,not character by character....pl ease help me out with this confusion....
    See more | Go to post

    Leave a comment:


  • thanking bonfa and donback for your replies,i think i have got it..you are saying that:-
    if char is unsigned then comparison of ch with eof(always negative)....wi ll nver cause the loop to end...and if eof is within a valid character range,then...so me character will be mistakenly taken as
    eof......did i get it right now... :)
    See more | Go to post

    Leave a comment:


  • okay i got it what you are trying to say is that,there is no character corresponding,. .to eof.....so we cant compare a character to eof..hmmm,but when eof is -1 and char range from -128 to +127 ,,then there has to be some character corresponding to -1 no...
    See more | Go to post

    Leave a comment:


  • @donbock but eof=-1,and even char can be negative,,then howcome,,,casti ng is wrong..........
    See more | Go to post

    Leave a comment:


  • yeah u r right...char range from -128 to 127..its okay but in the question getchar() returns unsigned integer value of characters only..so there should be no problem in casting.....
    See more | Go to post

    Leave a comment:


  • @banfa i dont think there is any problem in casting the return value of getchar,,,first of all getchar returns unsigned int,not just any int(yeah it returns negative value in case of end of file..)moreove in case of character to integrs type conversion,ther e is never of problem ...u can always cast a character to integer and integer to a character.....
    See more | Go to post

    Leave a comment:


  • What does getchar return if it reads the "enter"...?

    When you type one character and press enter, it prints two values, so it turns out that it does read "enter" from the input buffer. What does getchar actually return on reading enter? Moreover I can't understand why fflush(stdin) doesn't have any effect on the output when you type a string like("bytes")an d then press enter.

    Code:
    #include <stdio.h>
    /* count characters in input; 2nd version */
    void main()
    ...
    See more | Go to post
    Last edited by Niheel; Jan 26 '11, 12:10 AM. Reason: Spelling, grammar, punctuation.
No activity results to display
Show More
Working...