[Error] redefinition of 'int main'

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Duong Dinh Phuc
    New Member
    • Oct 2019
    • 1

    [Error] redefinition of 'int main'

    I encountered a problem when running C program. How to solve that problem. I use Dev-C++ 5.11

    Code here:

    #include <stdio.h>

    int stringCount(int n){
    int count = 0;
    while(n >= 10){
    n /= 10;
    count++;
    }
    return count;
    }

    int stringEnd(int n)
    {
    return n % 10;
    }

    int main()
    {
    /* @function : dem chu so
    * @var : int n
    * @return : stringCount, stringEnd
    */
    int n;
    printf("Nhap so tu nhien n : ");scanf("% d", &n);
    if(n > 0){
    printf("So luong chu so cua so tu nhien %d la %d", n, stringCount(n)+ 1);
    printf("\nChu so cuoi cung la : %d ", stringEnd(n));
    }else{
    printf("Ban phai nhap 1 so > 0");
    }
    return 0;
    }
  • dev7060
    Recognized Expert Contributor
    • Mar 2017
    • 656

    #2
    The code has no compilation errors. I tested it in Dev-C++ 5.11 as well. Post your screenshots.

    Comment

    Working...