| | |
error in debugging C code
![]() |
•
•
Join Date: Jul 2009
Posts: 11
Reputation:
Solved Threads: 0
Hi all,
First of all Thanks for all your last responses ,
Here I have one problem in debugging the below code.
It builds without any errors but it doesn't debugg or says some errors.
I created a exe file and when I try to run the file it doesn't run. It doesn't create a file in the C:\Temp drive
Any one could debug this?
I debugged this code in VS2005 as C project. Is there any change to be made in the system environmental set up? Any change in the VS studio settings?
Anyone help me? I am facing this problem last 48 hrs.
here, GVS = C:\temp
-------------------------------------------------test2.cpp--------------------------------
First of all Thanks for all your last responses ,
Here I have one problem in debugging the below code.
It builds without any errors but it doesn't debugg or says some errors.
I created a exe file and when I try to run the file it doesn't run. It doesn't create a file in the C:\Temp drive
Any one could debug this?
I debugged this code in VS2005 as C project. Is there any change to be made in the system environmental set up? Any change in the VS studio settings?
Anyone help me? I am facing this problem last 48 hrs.
here, GVS = C:\temp
-------------------------------------------------test2.cpp--------------------------------
C Syntax (Toggle Plain Text)
#include <stdio.h> #include <stdlib.h> #define ARG_ERROR 1 int main(int argc, char **argv) { FILE *fperr; char CARTERR[255]; while(argc--) printf("%s\n", *argv++); #ifdef WIN32 sprintf( CARTERR,"%s\\%s",getenv("GVS"),_CARTERR); #endif if( argc < 3) { printf( "Error in document\n"); fperr = fopen( CARTERR,"w"); fprintf( fperr,"%d:Error %s",ARG_ERROR); fclose( fperr); return( ARG_ERROR); } exit(EXIT_SUCCESS); }
Last edited by John A; Sep 3rd, 2009 at 8:51 pm. Reason: added code tags
|Selva|
•
•
Join Date: Mar 2008
Posts: 1,400
Reputation:
Solved Threads: 113
I'm surprised you figured out how to attach images. You've been here long enough to know how code-tags work, so please use them.
I need pageviews! most fun profile ever :)
Not getting an error for the undefined _CARTERR should indicate that WIN32 is not defined. So CARTERR is never filled with a string. So you try to open a file given by an undefined filename. This likely fails, but you don't check for success. So you probably try to fprintf to NULL.
Adding error-checking code would have caught this.
Adding error-checking code would have caught this.
"One of the methods used by statists to destroy capitalism consists in establishing controls that tie a given industry hand and foot, making it unable to solve its problems, then declaring that freedom has failed and stronger controls are necessary." --Ayn Rand
•
•
Join Date: Jul 2009
Posts: 11
Reputation:
Solved Threads: 0
•
•
•
•
Not getting an error for the undefined _CARTERR should indicate that WIN32 is not defined. So CARTERR is never filled with a string. So you try to open a file given by an undefined filename. This likely fails, but you don't check for success. So you probably try to fprintf to NULL.
Adding error-checking code would have caught this.
I cant understand what you mean in the above lines. Could you explain more?
|Selva|
•
•
•
•
I have defined CARTERR as char CARTERR[255]; so I din't get the error or warining !
I cant understand what you mean in the above lines. Could you explain more?
_CARTERR I meant _CARTERR , not CARTERR . 
Hopefully my last post makes sense now.

Change
#ifdef WIN32 to #if 1 for a moment. C Syntax (Toggle Plain Text)
main.c: In function `main': main.c:13: error: `_CARTERR' undeclared (first use in this function)
#if 0 . Which attempted build matches the output you see for #ifdef WIN32 ? For me, it matches the #if 0 case. Which tells me that this line is not compiled: C Syntax (Toggle Plain Text)
sprintf( CARTERR,"%s\\%s",getenv("GVS"),_CARTERR);
"One of the methods used by statists to destroy capitalism consists in establishing controls that tie a given industry hand and foot, making it unable to solve its problems, then declaring that freedom has failed and stronger controls are necessary." --Ayn Rand
•
•
•
•
Then change it to #if 0 . Which attempted build matches the output you see for #ifdef WIN32 ? For me, it matches the #if 0 case. Which tells me that this line is not compiled:
or linker internally does start with _ or __ .
Nothing like a kernel pannic !
http://predef.sourceforge.net/preos.html#sec24
No. I meant exactly what I said.
No. I meant exactly what I said.
"One of the methods used by statists to destroy capitalism consists in establishing controls that tie a given industry hand and foot, making it unable to solve its problems, then declaring that freedom has failed and stronger controls are necessary." --Ayn Rand
![]() |
Similar Threads
- Retrieving the number that the of error line of code? (PHP)
- codes showing error when debugging. (ASP.NET)
- Index error in PHP code (PHP)
- Need Help in debugging this code. (C)
- Help. Parse error in PHP code (PHP)
- compiling error, tried debugging but no luck (C)
- compiling error - help (C++)
- Help with error checking code (C++)
Other Threads in the C Forum
- Previous Thread: How to recursively list files/directories in current directory ?
- Next Thread: RSA Encryption, S.O.S. Emergency Distress Signal
| Thread Tools | Search this Thread |
adobe api array arrays binarysearch calculate char cm convert copyanyfile copypdffile cprogramme createcopyoffile createprocess() csyntax directory dynamic feet fflush file floatingpointvalidation fork forloop frequency getlasterror givemetehcodez global graphics gtkgcurlcompiling hacking hardware highest homework i/o ide inches incrementoperators intmain() iso kernel kilometer km linked linkedlist linux linuxsegmentationfault list locate logical_drives loopinsideloop. match matrix microsoft motherboard mqqueue mysql oddnumber odf open opensource openwebfoundation owf pattern pdf performance pointer posix power probleminc program programming pyramidusingturboccodes read recursion recv recvblocked repetition research scanf scheduling segmentationfault send shape socketprograming socketprogramming stack standard strchr string suggestions systemcall test unix urboc user variable voidmain() wab win32api windows.h






