Thread: Problems compiling

  1. #1
    Registered User
    Join Date
    Aug 2016
    Posts
    2

    Post Problems compiling

    Hi people. I'm new in this C programming issue and I have had some problems. It happens with Code::Blocks. When I complete my project and run the program it has no problem. I can type in the data, numbers, letters or whatever to make it work, but once I press Enter it jumps to a new line and does nothing at all. I even have to close the window with the X. I have an example with a basic program that finds a quotient and the rest with two numbers the user chooses. I don't know if it is a problem with the IDE or with my hideous coding, but I'd appreciate if you could give me a hand. Thanx.

    Code:
    #include <stdio.h>#include <conio.h>
    
    
    void div(int a, int b)
    {
        int i,result=0,rest=0,p;
        for(i=1;i=a;i++)
            if((i*b)<a)
            result=i;
        else
    
    
    
    
    
    
            p=result*b;
            rest=a-p;
    
    
            printf("The quotient is %d and the reminder is %d",result,rest);
    
    
            return;
    }
    
    
    
    
    int main()
    {
        int a,b;
    
    
        printf("Please type the dividend: \n");
        scanf("%d",&a);
        printf("Now, type the divisor. REMEMBER TO CHOOSE A SMALLER NUMBER: \n");
        scanf("%d",&b);
    
    
        div(a,b);
    
    
        return 0;
    
    
    }

  2. #2
    Registered User MutantJohn's Avatar
    Join Date
    Feb 2013
    Posts
    2,665
    Code:
    for(i=1;i=a;i++)
    This looks problematic

  3. #3
    Gawking at stupidity
    Join Date
    Jul 2004
    Location
    Oregon, USA
    Posts
    3,218
    Not enough blank lines. You should have no fewer than 13 blank lines separating every line of code. In all seriousness though, if you clean up your code (remove extraneous blank lines and fix indenting) it will help you find your issue.
    If you understand what you're doing, you're not learning anything.

  4. #4
    Its hard... But im here swgh's Avatar
    Join Date
    Apr 2005
    Location
    England
    Posts
    1,687
    Do not use conio.h the header library is not supported in the standard
    and contains outdated functions. Also, you do not need to have a return
    statement in a void-returning function unless it's used as an alternative exit
    path.
    Double Helix STL

  5. #5
    Registered User
    Join Date
    Aug 2016
    Posts
    2
    Why is it problematic?

  6. #6
    Programming Wraith GReaper's Avatar
    Join Date
    Apr 2009
    Location
    Greece
    Posts
    2,731
    Quote Originally Posted by jlb View Post
    Why is it problematic?
    Because assignment(=) is totally different to equality(==).
    Devoted my life to programming...

  7. #7
    Registered User MutantJohn's Avatar
    Join Date
    Feb 2013
    Posts
    2,665
    Also, make sure you look up how to compile in Code::Blocks with the flags -Wall -pedantic. They'll help you catch a lot of bugs and ensure that your code is standards-compliant.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Problems compiling c++11
    By serge in forum C++ Programming
    Replies: 5
    Last Post: 03-10-2015, 07:54 AM
  2. Problems compiling this SDL app
    By Rider in forum C++ Programming
    Replies: 3
    Last Post: 03-27-2007, 12:22 PM
  3. problems compiling
    By dnr72 in forum C Programming
    Replies: 3
    Last Post: 01-17-2005, 04:29 PM
  4. --> Compiling Problems -->
    By j0hnb1ank in forum C Programming
    Replies: 1
    Last Post: 01-28-2003, 06:41 AM
  5. Compiling Problems...
    By Hydro in forum C++ Programming
    Replies: 2
    Last Post: 01-23-2002, 06:49 PM

Tags for this Thread