Turbo C/C++ and other junk compilers help, discussions and queries here

somulesnar

Journeyman
well, there was a reason why I said not to learn C as your first language in India. You're most likely to choose the wrong path. Indians have raped the beautiful language by sticking with Turbo C/C++ and writing useless books. eg, Sumita Arora, Yashavant Kanetkar etc. :(

The C Programming Language 8120305965: Book: Brian W. Kernighan (9788120305960) | Flipkart.com

Buy this. Very cheap and this is written by the creators of C.

Agree with you man. I am tired of this turbo C compiler. Sorry guys for the inconvenience, would try to post better codes coping up the standard. And i am going to get code blocks for sure.

BTW i am using programming in C- By Byron S Gotfried (schaum's outlines).
 
dosbox and c++

Hi,
I have a 64bit windows 7 Home Premium computer and I want to run turbo c++ 4.5 in it. Need help.

I tried running installation file through dosbox but it says the file must run under windows. I installed it on my pen drive and run tcw.exe but the result is same-"the file must be run under windows". Again direct installation on laptop gives compatibility error.

I need it to do dos programming through c. I couldn't understand DJGPP so couldn't install it.

Please help.
 

saswat23

Human Spambot
Re: dosbox and c++

This might help: Turbo C for Windows 7 64 Bit download with one click installer | Indian Exam Updates: IndiaExam
 

Mario

Ambassador of Buzz
Re: dosbox and c++

Hi,
I have a 64bit windows 7 Home Premium computer and I want to run turbo c++ 4.5 in it. Need help.

I tried running installation file through dosbox but it says the file must run under windows. I installed it on my pen drive and run tcw.exe but the result is same-"the file must be run under windows". Again direct installation on laptop gives compatibility error.

I need it to do dos programming through c. I couldn't understand DJGPP so couldn't install it.

Please help.

Trash that compiler NOW! That is, if you want to learn "C" and not "101 ways to how to not program in C!"
 

akii17kr

Journeyman
pLz. help in solivng a C question...

*img195.imageshack.us/img195/5661/salary.jpg
actually i am stuck at one question
after running it it tells always SALARY=0.
i amnot able to find out error so help me in finding error.

question is in attached URL with questi0n and solution which is given in the book "let us c"

and i tried to do it in the way which my computer teacher taught me earlier

here's my coding:


#include<stdio.h>
#include<conio.h>
void main()
{
clrscr();
char g,pg,ug;
int yos,q,s=0;

printf("\n Enter the gender , year of service ,qualification:");
scanf(" %c %d %d ",&g,&yos,&q);

if(g=='m' && yos>=10 && q==pg)
s=15000;

else if((g=='m' && yos>=10 && q==ug)||(g=='m' && yos<10 && q==pg))
s=10000;

else if(g=='m' && yos<10 && q==ug)
s=7000;

else if(g=='f' && yos>=10 && q==pg)
s=12000;

else if(g=='f' && yos>=10 && q==ug)
s=9000;

else if(g=='f' && yos<10 && q==pg)
s=10000;

else if(g=='f' && yos<10 && q==ug)
s=6000;

printf("\n salary of employee=%d\n",s);
getch();
}




and btw i also tried da method given in book and still it does not tell the salaray....

here's book method :



#include<stdio.h>
int main()
{
char g;
int yos,qual,sal=0;

printf("Enter gender ,year of service and qualifications(0=g,1=pg):");
scanf("%c%d%d",&g,&yos,&qual);

if(g=='m' && yos>=10 && qual==1)
sal=15000;

else if((g=='m' && yos>=10 && qual==0)||(g=='m' && yos<10 && qual==1))
sal=10000;

else if(g=='m' && yos<10 && qual==0)
sal=7000;

else if(g=='f' && yos>=10 && qual==1)
sal=12000;

else if(g=='f' && yos>=10 && qual==0)
sal=9000;

else if(g=='f' && yos<10 && qual==1)
sal=10000;

else if(g=='f' && yos<10 && qual==0)
sal=6000;

printf("\n salary of employee=%d\n",sal);
return 0;



thx in advance
 

rijinpk1

Aspiring Novelist
Re: pLz. help in solivng a C question...

printf("\n Enter the gender , year of service ,qualification:\n");
try that.
Put \n at the end of printf. This should solve. Try and reply
 

akii17kr

Journeyman
Re: pLz. help in solivng a C question...

printf("\n Enter the gender , year of service ,qualification:\n");
try that.
Put \n at the end of printf. This should solve. Try and reply
it too duz'nt work bro
can u own try dis question in ur own way if u have time well its not necessary but if u can do den plz. post the code here
thx..

#include<stdio.h>
#include<conio.h>
void main()
{
clrscr();
char g,q[2];
int yos,s=0;
printf("\n Enter the gender , year of service ,qualification:");
scanf(" %c %d %s ",&g,&yos,q);
if(g=='m' && yos>=10 && q=="pg")
s=15000;
else if((g=='m' && yos>=10 && q=="ug")||(g=='m' && yos<10 && q=="pg"))
s=10000;
else if(g=='m' && yos<10 && q=="ug")
s=7000;
else if(g=='f' && yos>=10 && q== "pg")
s=12000;
else if(g=='f' && yos>=10 && q=="ug")
s=9000;
else if(g=='f' && yos<10 && q=="pg")
s=10000;
else if(g=='f' && yos<10 && q=="ug")
s=6000;
printf("\n salary of employee=%d\n",s);
getch();
}

well only difference with ur coding and my coding is dat u hv putted " and " in b/w the ug and pg

i've tried it too but it gives error of cannot convert char to char

does it work on ur pc or lappy ??
btw i am using turbo c++
 

rijinpk1

Aspiring Novelist
Re: pLz. help in solivng a C question...

#include<stdio.h>
#include<conio.h>
void main()
{
clrscr();
char g,q;
int yos,s=0;
printf("\n Enter the gender , year of service ,qualification:");
scanf(" %c %d %c ",&g,&yos,&q);
if(g=='m' && yos>=10 && q=="pg")
s=15000;
else if((g=='m' && yos>=10 && q=="ug")||(g=='m' && yos<10 && q=="pg"))
s=10000;
else if(g=='m' && yos<10 && q=="ug")
s=7000;
else if(g=='f' && yos>=10 && q== "pg")
s=12000;
else if(g=='f' && yos>=10 && q=="ug")
s=9000;
else if(g=='f' && yos<10 && q=="pg")
s=10000;
else if(g=='f' && yos<10 && q=="ug")
s=6000;
printf("\n salary of employee=%d\n",s);
getch();
}

Sry for my deleted post. q refers either pg or ug . Dont store it as integer variable. Use char.
 

akii17kr

Journeyman
Re: pLz. help in solivng a C question...

#include<stdio.h>
#include<conio.h>
void main()
{
clrscr();
char g,q;
int yos,s=0;
printf("\n Enter the gender , year of service ,qualification:");
scanf(" %c %d %c ",&g,&yos,&q);
if(g=='m' && yos>=10 && q=="pg")
s=15000;
else if((g=='m' && yos>=10 && q=="ug")||(g=='m' && yos<10 && q=="pg"))
s=10000;
else if(g=='m' && yos<10 && q=="ug")
s=7000;
else if(g=='f' && yos>=10 && q== "pg")
s=12000;
else if(g=='f' && yos>=10 && q=="ug")
s=9000;
else if(g=='f' && yos<10 && q=="pg")
s=10000;
else if(g=='f' && yos<10 && q=="ug")
s=6000;
printf("\n salary of employee=%d\n",s);
getch();
}

Sry for my deleted post. q refers either pg or ug . Dont store it as integer variable. Use char.

i've also tried dat bro...but still same orblm.. SALARY=0 . :p
 

Mario

Ambassador of Buzz
Re: pLz. help in solivng a C question...

i've also tried dat bro...but still same orblm.. SALARY=0 . :p

Isnt char q only going to store a single character? But you are comparing multiple characters in your condition statement.
 

raj_55555

Journeyman
Re: pLz. help in solivng a C question...

rijinpk1 said:
This little part of your code has disturbingly large number of issues.

1. q is a character, not a string. You can do q='p' or q='g'. But not both at once, simply because it doesn't have the space to keep both the characters at once.
Just printf() the value of q before comparing and you'll know what I am saying.

2. Even if q was a string(which it is not), and you could store "pg" into q; you coudn't possibly check for a match by using "==" operand. This only works for numbers, you need strcmp() function (declared in string.h) to compare strings.

3. In the previous line, i.e. the scanf, you're not validating whether it succeeded or not. You must always check the input functions for success, never assume anything.
 
Last edited:
Re: C/C++ Beginner's Guide and Post Basic Questions here

Kindly provide an explanation for this code snippet. I couldn't understand how the output was calculated.

int main()
{
int a=1;
a=(++a)+(++a);
printf("a value is %d",a);
return 0;
}

when run in Turbo C, this program produces 6 as output. How is it achieved.?
 

Anish

Spectre
Re: C/C++ Beginner's Guide and Post Basic Questions here

Kindly provide an explanation for this code snippet. I couldn't understand how the output was calculated.

int main()
{
int a=1;
a=(++a)+(++a);
printf("a value is %d",a);
return 0;
}

when run in Turbo C, this program produces 6 as output. How is it achieved.?

How about this? the o/p is calculated by this method...
#include "stdio.h"
int main()
{
int a=1;
a=(++a);
printf("a value is %d",a);
a=(++a);
printf("a value is %d",a);
a=a+a;
printf("a value is %d",a);
return 0;
}

Like the above code,
the compiler first does the ++a and stores the result (2) in a.
Then it computes ++a again and stores back the result (3) in a (overwrites 2 in this case with 3)
now, adding both, will add 3+3 and gives you answer as 6.

EDIT: Use GCC
 
Last edited:

nims11

BIOS Terminator
^^ What you said is just shooting in the dark. I believe the answer to the question asked by rakesh is undefined and is compiler dependent. see Sequence point - Wikipedia, the free encyclopedia
 

Anish

Spectre
^^ What you said is just shooting in the dark. I believe the answer to the question asked by rakesh is undefined and is compiler dependent. see Sequence point - Wikipedia, the free encyclopedia

Yes, its just my assumption of how the code works. But I get the same result even while using GCC.
PS: I just know to play with C and data structures. Not indepth of it. :(
 
Re: C/C++ Beginner's Guide and Post Basic Questions here

#include "stdio.h"
int main()
{
int a=1;
a=(++a);
printf("a value is %d",a);
a=(++a);
printf("a value is %d",a);
a=a+a;
printf("a value is %d",a);
return 0;
}

Like the above code,
the compiler first does the ++a and stores the result (2) in a.
Then it computes ++a again and stores back the result (3) in a (overwrites 2 in this case with 3)
now, adding both, will add 3+3 and gives you answer as 6.

Thanks for the explanation. BTW I am using Turbo C as part of my college lab manual, not willingly. I practice using CodeBlocks back at home. [Anna Univ syllabus strictly mentions to prepare with Turbo C for labs]
 

quagmire

Allllright !
Re: C/C++ Beginner's Guide and Post Basic Questions here

Guys need a little help in Code Blocks:

I am working on a linked list program in Data Structures: The aim is to create an ordered linked list.
The following code works perfectly fine in TurboC:
Code:
//Program to create an ardered linked list

#include<stdio.h>
#include<conio.h>
#include<malloc.h>
#include<process.h>

struct node
{
    int info;
    struct node *link;
};

typedef struct node *NODE;

NODE getNode()
{
    NODE x;
    x=(NODE)malloc(sizeof(struct node));
    if(x==NULL)
    {
        printf("\nOVER FLOW");
        exit(0);
    }
    return x;
}

NODE insertOrder(NODE first, int item)
{
    NODE prev=NULL, cur=NULL, temp;
    temp= getNode();
    temp->info=item;
    temp->link=NULL;

    if(first==NULL)
    {
        return temp;
    }
    if(first->link==NULL)
    {
        if(item>first->info)
        {
            first->link=temp;
            return first;
        }

        if(item<=first->info)
        {
            temp->link=first;
            return temp;
        }
    }
    prev=NULL;
    cur=first;

    while((cur!=NULL)&&(item>temp->info))
    {
        prev=cur;
        cur=cur->link;
    }

    if(cur==NULL)
    {
        cur->link=temp;
        temp->link=NULL;
        return first;
    }
    prev->link=temp;
    temp->link=cur;
    return first;
}

void display(NODE first)
{
    NODE temp;
    temp=first;
    if (first == NULL)
    {
        printf("List is empty \n");
        getch();
        exit(0);
    }
    printf("\nThe contents of singly linked list are:\n");
    temp=first;

    while(temp!= NULL)
    {
        printf("\t%d",temp->info);
        temp=temp->link;
    }
}


void main()
{
    NODE first=NULL;
    int item, choice;
    for( ; ; )
    {
        printf(" \nEnter you choice:\n1. Insert();\n2. Display()\n3. Exit()\n\n");
        scanf("%d",&choice);

        switch(choice)
        {
            case 1: printf("\nEnter the item:\n");
                    scanf("%d",&item);
                    first = insertOrder(first,item);
                    break;

            case 2: display(first);
                    break;

            default: exit(0);
        }
    }
}


But in Codeblocks I get an output saying:
*www.thinkdigit.com/forum/attachment.php?attachmentid=12226&d=1379837682
codeblocks crash.JPG
(Most usually when I try to enter the third info/item)

I just read on stackoverflow that '0xc0000005' is some kind of invalid pointer error.. I dont see any such in my code. :|

Any mistakes I've made?

cplusplus forum
 

skeletor

Chosen of the Omnissiah
Read the first post of this thread.

Code properly. Which book are you referring to? conio.h? void main()?

Don't read from it.
 
Top Bottom