Thread: Cygwin Help

  1. #1
    Registered User
    Join Date
    Jan 2009
    Posts
    10

    Cygwin Help

    Hello, i am new to programming.
    I know a little bit of C and am trying to learn pascal.
    I have Cygwin On my computer, and i used to use it to program for psp.
    The Cygwin Dash Barely notices any code, it notices some C and zer Pascal.
    For Example:
    Code:
    Craig@computer ~
    $ #include <stdio.h>
    
    Craig@computer ~
    $
    
    Craig@computer ~
    $ main(){
    > POINT pt;
    > getcursorpos(&pt);
    bash: syntax error near unexpected token `&'
    
    Craig@computer ~
    $ }
    Also, it doesnt recognize variables like 'int' type as it reads:
    "bash: syntax error near unexpected token 'int'"

    I think What I need is some libraries, so if somebody could point me to some libraries for both C and Pascal, and tell me where to save them under cygwin, i would be very appreciative. Thank You.

    Oh, and By the way, i am on Windows XP professional if that matters.

  2. #2
    Woof, woof! zacs7's Avatar
    Join Date
    Mar 2007
    Location
    Australia
    Posts
    3,459
    Presumably you're using bash, which speaks bash not C.

    > I think What I need is some libraries
    Or a text editor and a C compiler...

  3. #3
    Registered User
    Join Date
    Jan 2009
    Posts
    10
    I used to use cygwin to compile PSP programs that i wrote in C.
    That was using psptoolchain. So ur saying i should get a comiler and text editor?
    Ive thought of taht before, but ive used cygwin to compile before, so i thought id use that. I have to try and find out the administration password, cause there is always sumthing going wrong when i try to download on this user. Ive actually tried to get crimson editor, which is what i used when i was doing psp. Thanks for the help, ima go mess around with it for a bit
    =p


    EDIT:
    Ok, i got a compiler(Bloodshed Dev-C++), it seems that my simple program wont show me the cordonites of the screen, it looks like a window pops up, but it shutsdown rightaway.
    Code:
    #include <windows.h>
    
    main(){
           POINT pt;
           GetCursorPos(&pt);
           }
    it comiled with no errors, but could somebody help me. The program is just to find the coordinates of the cursor on screen. Thank you.
    Last edited by wannabe723; 01-01-2009 at 02:09 AM.

  4. #4
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    28,413
    Quote Originally Posted by wannabe723
    Ok, i got a compiler(Bloodshed Dev-C++), it seems that my simple program wont show me the cordonites of the screen, it looks like a window pops up, but it shutsdown rightaway.
    Read the FAQ concerning How do I Stop my Windows Console from disappearing everytime I run my program?

    Actually, in view that maintenance on Dev-C++ has stopped yet the program still has a number of bugs, it would be better to use Code::Blocks or Microsoft Visual Studio 2008 Express.
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  5. #5
    Registered User
    Join Date
    Jan 2009
    Posts
    10
    Thank you guys a bunch, i finally got this working, i had to use cygwin to run the compiled code, and here it is:
    Code:
    #include <stdio.h>
    #include <windows.h>
    
    main(){
           POINT pt;
           GetCursorPos(&pt);
      printf("%pt"); //Added this cause the program had no output =P
           }
    And when i ran the program on cygwin:

    Code:
    Craig@computer ~
    $ ls
     getcursorpos  helloworld
         
    Craig@computer ~
    $ cd getcursorpos
    
    Craig@computer ~/getcursorpos
    $ ls
    getcursorpos.exe
    
    Craig@computer ~/getcursorpos
    $ ./getcursorpos.exe
    003E2478t
    Craig@computer ~/getcursorpos
    $
    so the output is "003E2478t". How do i get this into x,y coordinates?

  6. #6
    Reverse Engineer maxorator's Avatar
    Join Date
    Aug 2005
    Location
    Estonia
    Posts
    2,318
    "The Internet treats censorship as damage and routes around it." - John Gilmore

  7. #7
    Registered User
    Join Date
    Jan 2009
    Posts
    10
    Lolz, yeah, i shoulda checked it up, all i remembered from psp programming was that there was a % in it. Isnt it wierd that it still comiled with no errors?

    I redid my code to this:

    Code:
    #include <stdio.h>
    #include <windows.h>
    
    main(){
           POINT pt;
           GetCursorPos(&pt);
           printf("%p",pt);
           }
    And cygwin outputed this:
    000000C5

    What does this mean!!?? is it like the address of that pixel? How do i get it into x,y format(i need x,y for pascal!);

  8. #8
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,336
    The Windows POINT is a structure that contains two members, x and y, which means you're going to have to print them out yourself.

    Code:
    printf("(%ld, %ld)\n", pt.x, pt.y);
    As for the other, gcc will tell you
    Code:
    warning: too few arguments for format
    provided you don't silence the warnings.

  9. #9
    Registered User
    Join Date
    Jan 2009
    Posts
    10
    Ahhhh... thank you it worked. This little tiny project tells me i have a whole lot to learn =p

  10. #10
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,660
    Again, %p prints pointers.
    You need something like
    printf( "%d %d", pt.x, pt.y );

    But you need to research the names and types of the struct members, and the associated printf format strings.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  11. #11
    Registered User
    Join Date
    Jul 2008
    Posts
    3
    wannabe723,
    Take a look here, please:
    http://cboard.cprogramming.com/showthread.php?t=74079

    A good book on C programming is your better choice!!!

    Kind regards!

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. NetBeans + Cygwin driving me insane
    By Del75 in forum C++ Programming
    Replies: 4
    Last Post: 08-17-2008, 05:03 AM
  2. cygwin sshd weird behavior
    By jEssYcAt in forum Tech Board
    Replies: 6
    Last Post: 05-19-2008, 02:05 PM
  3. Problems with compiling code in cygwin
    By firyace in forum C++ Programming
    Replies: 4
    Last Post: 06-01-2007, 08:16 AM
  4. Cygwin and coLinux
    By Mario F. in forum Tech Board
    Replies: 8
    Last Post: 07-03-2006, 02:00 PM
  5. Cygwin Server
    By osal in forum Networking/Device Communication
    Replies: 0
    Last Post: 03-07-2005, 12:58 PM