CrazyEngineers
  • Problem Concerning C Lang

    Updated: Oct 22, 2024
    Views: 1.1K
    Hello s
    I started learning C programming a month or two ago.
    I tried to use the clrscr(); fuction in the program
    i have included conio.n and stdio.h , but the compiler i use throws up "Undefined reference to clrscr()" error while compiling. Anyone know why? I googled ( as i usually do when i meet with a problem) but nothing..
    I am using the latest version of Code::Blocks
    - Thanks Sam 😁
    0
    Replies
Howdy guest!
Dear guest, you must be logged-in to participate on CrazyEngineers. We would love to have you as a member of our community. Consider creating an account or login.
Replies
  • Manish Goyal

    MemberSep 25, 2010

    it is conio.h not conio.n
    Are you sure? This action cannot be undone.
    Cancel
  • sam_from_hell

    MemberSep 25, 2010

    sorry typo
    *i included conio.h 😁
    Are you sure? This action cannot be undone.
    Cancel
  • Manish Goyal

    MemberSep 25, 2010

    can you post your program and which compiler are you using?
    Are you sure? This action cannot be undone.
    Cancel
  • sam_from_hell

    MemberSep 25, 2010

    This is a small program i learnt to compare two strings using strcmp()..
    I use CodeBlocks, and the GNU GCC compiler.




    #include<stdio.h>
    #include<conio.h>
    #include<string.h>
    int main (void)
    {
         char password[11]= {"qwerty"};
         char inputpassword[11]= "";
         char newpassword[11]="";
         char response[2]="";
         char responsey[2]="Y";
         char responsen[2]="N";
         int i=0;
         while (i<10)
         {
             printf("Enter Password :\n");
             gets(inputpassword);
             if (strcmp(password,inputpassword)==0)
                {
                   printf("Do u want to change password?[Y/N]:\n");
                   scanf("%s",response);
                   if (strcmpi(responsey,response)==0)
                      {
                          printf("Enter new password:\n");
                          scanf("%s", password);
                          printf("The new password is: %s\n", password);
                      }
                   else
                      {
                          printf("Welcome:\n");
                      }
                }
             else
                 {
                   //clrscr();
                   printf("Invalid Password\n");
                 }
             i++;
         }
         getch();
    }
    
    Are you sure? This action cannot be undone.
    Cancel
  • anandkumarjha

    MemberSep 25, 2010

    #include<stdio.h>
    #include<conio.h>
    #include<string.h>
    int main (void)
    {
    char password[11]= {"qwerty"};
    char inputpassword[11]= "";
    char newpassword[11]="";
    char response[2]="";
    char responsey[2]="Y";
    char responsen[2]="N";
    int i=0;
    while (i<10)
    {
    printf("Enter Password :\n");
    gets(inputpassword);
    if (strcmp(password,inputpassword)==0)
    {
    printf("Do u want to change password?[Y/N]:\n");
    scanf("%s",response);
    if (strcmp(responsey,response)==0)
    {
    printf("Enter new password:\n");
    scanf("%s", password);
    printf("The new password is: %s\n", password);
    }
    else
    {
    printf("Welcome:\n");
    }
    }
    else
    {
    //clrscr();
    printf("Invalid Password\n");
    }
    i++;
    }
    getch();
    }
    Try this code
    Are you sure? This action cannot be undone.
    Cancel
  • Manish Goyal

    MemberSep 25, 2010

    if you using gnu gcc compiler then conio.h will not work

    and also you have to include file as

    include<stdio>
    Are you sure? This action cannot be undone.
    Cancel
  • sam_from_hell

    MemberSep 25, 2010

    goyal420
    if you using gnu gcc compiler then conio.h will not work

    and also you have to include file as

    include<stdio>
    ok thanks, i will check it out 😁
    Are you sure? This action cannot be undone.
    Cancel
  • sam_from_hell

    MemberSep 27, 2010

    goyal420
    if you using gnu gcc compiler then conio.h will not work

    and also you have to include file as

    include<stdio>
    GNU GCC does support conio.h..
    the solution for the problem i originally posted is to use a user defined function that can be found here instead of clrscr(); ( u can create a header file from the code given in the end of the link)
    https://faq.cprogramming.com/cgi-bin/smartfaq.cgi?answer=1031963460&id=1043284385
    (found this after asking 3 people lol 😁 )
    also you cant use "include <stdio>" for some reason(maybe because i'm using c and not c++)
    it HAS to be #inlcude<stdio.h>
    --Thanks Sam 😁
    Are you sure? This action cannot be undone.
    Cancel
Home Channels Search Login Register