Path in graphics in C











up vote
0
down vote

favorite












I had been using graphics.h in my program for a while. I was facing problem in the path but I later resolved it. Now, I typed the wrong path in the initigraph() function but the program still worked. How is it possible?



Code1:



#include <graphics.h>
#include <stdio.h>
#include <conio.h>

int main()
{
char a ="vyfm";
int gd = DETECT, gm;
initgraph(&gd, &gm, a);

line(100,100, 200, 200);

getch();
closegraph();

return 0;
}


Code 2:



#include <graphics.h>
#include <stdio.h>
#include <conio.h>

int main()
{
char a ="C:\TC\BGI";
int gd = DETECT, gm;
initgraph(&gd, &gm, a);

line(100,100, 200, 200);

getch();
closegraph();

return 0;
}









share|improve this question
























  • My GOSH!!! This is an ANCIENT Turbo C API. The C++ language (to say nothing of computing in general) has changed a lot since then... As to your question: initgraph() initializes the graphics system, and loads some runtime files from the BG (Borland Graphics) directory. I guess your exe just didn't need any of those runtime files ;)
    – paulsm4
    Nov 17 at 6:08












  • I am using codeblocks
    – Keshav Saraf
    Nov 17 at 6:09










  • But how is it posiible that the initgraph function doesn't requires any directory?
    – Keshav Saraf
    Nov 17 at 6:12






  • 2




    @KeshavSaraf C:\TC\BGI is clearly Turbo C, ... BGI works only under MS-DOS so if you're really have CodeBlocks what BGI an OS you got or targeting? That might answer your question as different version of BGI might handle the parameters differently. IIRC WinBGI has different header so you have something else... graphics.h is meaningless as almost all gfx engine has such file ... your code is clearly ancient BGI
    – Spektre
    Nov 17 at 8:58








  • 2




    You asked a similar question here. SAD AND UNFORTUNATE FACT: even if your program does something "wrong" ... you WON'T (necessarily) get a compile error, and it MIGHT NOT even fail at runtime (at least not at first). It might "appear" to work. Those are the WORST kinds of bugs - the ones your customer finds, before you do :( Always beware "undefined behavior".
    – paulsm4
    Nov 17 at 22:24

















up vote
0
down vote

favorite












I had been using graphics.h in my program for a while. I was facing problem in the path but I later resolved it. Now, I typed the wrong path in the initigraph() function but the program still worked. How is it possible?



Code1:



#include <graphics.h>
#include <stdio.h>
#include <conio.h>

int main()
{
char a ="vyfm";
int gd = DETECT, gm;
initgraph(&gd, &gm, a);

line(100,100, 200, 200);

getch();
closegraph();

return 0;
}


Code 2:



#include <graphics.h>
#include <stdio.h>
#include <conio.h>

int main()
{
char a ="C:\TC\BGI";
int gd = DETECT, gm;
initgraph(&gd, &gm, a);

line(100,100, 200, 200);

getch();
closegraph();

return 0;
}









share|improve this question
























  • My GOSH!!! This is an ANCIENT Turbo C API. The C++ language (to say nothing of computing in general) has changed a lot since then... As to your question: initgraph() initializes the graphics system, and loads some runtime files from the BG (Borland Graphics) directory. I guess your exe just didn't need any of those runtime files ;)
    – paulsm4
    Nov 17 at 6:08












  • I am using codeblocks
    – Keshav Saraf
    Nov 17 at 6:09










  • But how is it posiible that the initgraph function doesn't requires any directory?
    – Keshav Saraf
    Nov 17 at 6:12






  • 2




    @KeshavSaraf C:\TC\BGI is clearly Turbo C, ... BGI works only under MS-DOS so if you're really have CodeBlocks what BGI an OS you got or targeting? That might answer your question as different version of BGI might handle the parameters differently. IIRC WinBGI has different header so you have something else... graphics.h is meaningless as almost all gfx engine has such file ... your code is clearly ancient BGI
    – Spektre
    Nov 17 at 8:58








  • 2




    You asked a similar question here. SAD AND UNFORTUNATE FACT: even if your program does something "wrong" ... you WON'T (necessarily) get a compile error, and it MIGHT NOT even fail at runtime (at least not at first). It might "appear" to work. Those are the WORST kinds of bugs - the ones your customer finds, before you do :( Always beware "undefined behavior".
    – paulsm4
    Nov 17 at 22:24















up vote
0
down vote

favorite









up vote
0
down vote

favorite











I had been using graphics.h in my program for a while. I was facing problem in the path but I later resolved it. Now, I typed the wrong path in the initigraph() function but the program still worked. How is it possible?



Code1:



#include <graphics.h>
#include <stdio.h>
#include <conio.h>

int main()
{
char a ="vyfm";
int gd = DETECT, gm;
initgraph(&gd, &gm, a);

line(100,100, 200, 200);

getch();
closegraph();

return 0;
}


Code 2:



#include <graphics.h>
#include <stdio.h>
#include <conio.h>

int main()
{
char a ="C:\TC\BGI";
int gd = DETECT, gm;
initgraph(&gd, &gm, a);

line(100,100, 200, 200);

getch();
closegraph();

return 0;
}









share|improve this question















I had been using graphics.h in my program for a while. I was facing problem in the path but I later resolved it. Now, I typed the wrong path in the initigraph() function but the program still worked. How is it possible?



Code1:



#include <graphics.h>
#include <stdio.h>
#include <conio.h>

int main()
{
char a ="vyfm";
int gd = DETECT, gm;
initgraph(&gd, &gm, a);

line(100,100, 200, 200);

getch();
closegraph();

return 0;
}


Code 2:



#include <graphics.h>
#include <stdio.h>
#include <conio.h>

int main()
{
char a ="C:\TC\BGI";
int gd = DETECT, gm;
initgraph(&gd, &gm, a);

line(100,100, 200, 200);

getch();
closegraph();

return 0;
}






turbo-c bgi






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 17 at 8:55









Spektre

28.7k645200




28.7k645200










asked Nov 17 at 6:06









Keshav Saraf

248




248












  • My GOSH!!! This is an ANCIENT Turbo C API. The C++ language (to say nothing of computing in general) has changed a lot since then... As to your question: initgraph() initializes the graphics system, and loads some runtime files from the BG (Borland Graphics) directory. I guess your exe just didn't need any of those runtime files ;)
    – paulsm4
    Nov 17 at 6:08












  • I am using codeblocks
    – Keshav Saraf
    Nov 17 at 6:09










  • But how is it posiible that the initgraph function doesn't requires any directory?
    – Keshav Saraf
    Nov 17 at 6:12






  • 2




    @KeshavSaraf C:\TC\BGI is clearly Turbo C, ... BGI works only under MS-DOS so if you're really have CodeBlocks what BGI an OS you got or targeting? That might answer your question as different version of BGI might handle the parameters differently. IIRC WinBGI has different header so you have something else... graphics.h is meaningless as almost all gfx engine has such file ... your code is clearly ancient BGI
    – Spektre
    Nov 17 at 8:58








  • 2




    You asked a similar question here. SAD AND UNFORTUNATE FACT: even if your program does something "wrong" ... you WON'T (necessarily) get a compile error, and it MIGHT NOT even fail at runtime (at least not at first). It might "appear" to work. Those are the WORST kinds of bugs - the ones your customer finds, before you do :( Always beware "undefined behavior".
    – paulsm4
    Nov 17 at 22:24




















  • My GOSH!!! This is an ANCIENT Turbo C API. The C++ language (to say nothing of computing in general) has changed a lot since then... As to your question: initgraph() initializes the graphics system, and loads some runtime files from the BG (Borland Graphics) directory. I guess your exe just didn't need any of those runtime files ;)
    – paulsm4
    Nov 17 at 6:08












  • I am using codeblocks
    – Keshav Saraf
    Nov 17 at 6:09










  • But how is it posiible that the initgraph function doesn't requires any directory?
    – Keshav Saraf
    Nov 17 at 6:12






  • 2




    @KeshavSaraf C:\TC\BGI is clearly Turbo C, ... BGI works only under MS-DOS so if you're really have CodeBlocks what BGI an OS you got or targeting? That might answer your question as different version of BGI might handle the parameters differently. IIRC WinBGI has different header so you have something else... graphics.h is meaningless as almost all gfx engine has such file ... your code is clearly ancient BGI
    – Spektre
    Nov 17 at 8:58








  • 2




    You asked a similar question here. SAD AND UNFORTUNATE FACT: even if your program does something "wrong" ... you WON'T (necessarily) get a compile error, and it MIGHT NOT even fail at runtime (at least not at first). It might "appear" to work. Those are the WORST kinds of bugs - the ones your customer finds, before you do :( Always beware "undefined behavior".
    – paulsm4
    Nov 17 at 22:24


















My GOSH!!! This is an ANCIENT Turbo C API. The C++ language (to say nothing of computing in general) has changed a lot since then... As to your question: initgraph() initializes the graphics system, and loads some runtime files from the BG (Borland Graphics) directory. I guess your exe just didn't need any of those runtime files ;)
– paulsm4
Nov 17 at 6:08






My GOSH!!! This is an ANCIENT Turbo C API. The C++ language (to say nothing of computing in general) has changed a lot since then... As to your question: initgraph() initializes the graphics system, and loads some runtime files from the BG (Borland Graphics) directory. I guess your exe just didn't need any of those runtime files ;)
– paulsm4
Nov 17 at 6:08














I am using codeblocks
– Keshav Saraf
Nov 17 at 6:09




I am using codeblocks
– Keshav Saraf
Nov 17 at 6:09












But how is it posiible that the initgraph function doesn't requires any directory?
– Keshav Saraf
Nov 17 at 6:12




But how is it posiible that the initgraph function doesn't requires any directory?
– Keshav Saraf
Nov 17 at 6:12




2




2




@KeshavSaraf C:\TC\BGI is clearly Turbo C, ... BGI works only under MS-DOS so if you're really have CodeBlocks what BGI an OS you got or targeting? That might answer your question as different version of BGI might handle the parameters differently. IIRC WinBGI has different header so you have something else... graphics.h is meaningless as almost all gfx engine has such file ... your code is clearly ancient BGI
– Spektre
Nov 17 at 8:58






@KeshavSaraf C:\TC\BGI is clearly Turbo C, ... BGI works only under MS-DOS so if you're really have CodeBlocks what BGI an OS you got or targeting? That might answer your question as different version of BGI might handle the parameters differently. IIRC WinBGI has different header so you have something else... graphics.h is meaningless as almost all gfx engine has such file ... your code is clearly ancient BGI
– Spektre
Nov 17 at 8:58






2




2




You asked a similar question here. SAD AND UNFORTUNATE FACT: even if your program does something "wrong" ... you WON'T (necessarily) get a compile error, and it MIGHT NOT even fail at runtime (at least not at first). It might "appear" to work. Those are the WORST kinds of bugs - the ones your customer finds, before you do :( Always beware "undefined behavior".
– paulsm4
Nov 17 at 22:24






You asked a similar question here. SAD AND UNFORTUNATE FACT: even if your program does something "wrong" ... you WON'T (necessarily) get a compile error, and it MIGHT NOT even fail at runtime (at least not at first). It might "appear" to work. Those are the WORST kinds of bugs - the ones your customer finds, before you do :( Always beware "undefined behavior".
– paulsm4
Nov 17 at 22:24














1 Answer
1






active

oldest

votes

















up vote
0
down vote













If you say that you are using codeblocks, be careful about compiling the code then run it. If you just use the "run" command in codeblocks it will just run your last exe, even if you current file is modified. The exe will be modified when you successfully compile your code. In this case your code should compile, but I think you missed this step.






share|improve this answer








New contributor




RpdStrike is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.


















  • I always use build and run option.
    – Keshav Saraf
    Nov 17 at 6:15











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














 

draft saved


draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53348687%2fpath-in-graphics-in-c%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes








up vote
0
down vote













If you say that you are using codeblocks, be careful about compiling the code then run it. If you just use the "run" command in codeblocks it will just run your last exe, even if you current file is modified. The exe will be modified when you successfully compile your code. In this case your code should compile, but I think you missed this step.






share|improve this answer








New contributor




RpdStrike is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.


















  • I always use build and run option.
    – Keshav Saraf
    Nov 17 at 6:15















up vote
0
down vote













If you say that you are using codeblocks, be careful about compiling the code then run it. If you just use the "run" command in codeblocks it will just run your last exe, even if you current file is modified. The exe will be modified when you successfully compile your code. In this case your code should compile, but I think you missed this step.






share|improve this answer








New contributor




RpdStrike is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.


















  • I always use build and run option.
    – Keshav Saraf
    Nov 17 at 6:15













up vote
0
down vote










up vote
0
down vote









If you say that you are using codeblocks, be careful about compiling the code then run it. If you just use the "run" command in codeblocks it will just run your last exe, even if you current file is modified. The exe will be modified when you successfully compile your code. In this case your code should compile, but I think you missed this step.






share|improve this answer








New contributor




RpdStrike is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









If you say that you are using codeblocks, be careful about compiling the code then run it. If you just use the "run" command in codeblocks it will just run your last exe, even if you current file is modified. The exe will be modified when you successfully compile your code. In this case your code should compile, but I think you missed this step.







share|improve this answer








New contributor




RpdStrike is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









share|improve this answer



share|improve this answer






New contributor




RpdStrike is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









answered Nov 17 at 6:13









RpdStrike

11




11




New contributor




RpdStrike is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.





New contributor





RpdStrike is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.






RpdStrike is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.












  • I always use build and run option.
    – Keshav Saraf
    Nov 17 at 6:15


















  • I always use build and run option.
    – Keshav Saraf
    Nov 17 at 6:15
















I always use build and run option.
– Keshav Saraf
Nov 17 at 6:15




I always use build and run option.
– Keshav Saraf
Nov 17 at 6:15


















 

draft saved


draft discarded



















































 


draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53348687%2fpath-in-graphics-in-c%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

If I really need a card on my start hand, how many mulligans make sense? [duplicate]

Alcedinidae

Can an atomic nucleus contain both particles and antiparticles? [duplicate]