| | |
Debug assertion failed problem
![]() |
•
•
Join Date: Dec 2006
Posts: 7
Reputation:
Solved Threads: 0
I have a debug assertion failed problem with akrip code. That code is downloadable from http://akrip.sourceforge.net/simple.c
I have add a new code to function RipAudio(...) where i want to add new folder and name the file to it.
In original code fopen() function save the file to the root of exe but i made it better for me and put it to save the file to the new folder.
The problem is if i try to cange fopen first parameter to str what collect full path to new folder and file in it come to the program some Debug Assertion Failed. That error is in the same RipAudio(...) function but in fwrite function. I dont understand how my fopen- function affect with fwrite- function.
Error message gives "Expression: (stream != NULL)" message of fwrite.c. Is my getcurrentdirectory - createdirectory code right?
I have add a new code to function RipAudio(...) where i want to add new folder and name the file to it.
C Syntax (Toggle Plain Text)
void RipAudio( HCDROM hCD, DWORD dwStart, DWORD dwLen, int song ) { DWORD dwStatus; FILE *fp; DWORD num2rip = 26; int retries; LPTRACKBUF t; int c = 0; DWORD numWritten = 0; char songname[MAX_PATH-1] = {0}; char str[MAX_PATH-1] = {0}; char temp[] = "Songs"; t = NewTrackBuf( 26 ); if ( !t ) return; GetCurrentDirectory(MAX_PATH, str); CreateDirectory(temp, NULL); sprintf(str, "%s%s", str, temp); sprintf(str, "%s\\track%d.wav", str, song); sprintf(songname, "c:\\track%d.wav", song); // sprintf(songname, str, song); fp = fopen( str, "w+b" ); writeWavHeader( fp, 0 ); printf( "Beginning to rip %d sectors starting at sector %d\n", dwLen, dwStart ); while( dwLen ) { if ( !( c++ % 5) ) printf( "%d: %d\n", dwStart, dwLen ); if ( dwLen < num2rip ) num2rip = dwLen; retries = 3; dwStatus = SS_ERR; while ( retries-- && (dwStatus != SS_COMP) ) { t->numFrames = num2rip; t->startOffset = 0; t->len = 0; t->startFrame = dwStart; dwStatus = ReadCDAudioLBA( hCD, t ); } if ( dwStatus == SS_COMP ) { fwrite( t->buf + t->startOffset, 1, t->len, fp ); numWritten += t->len; ...
In original code fopen() function save the file to the root of exe but i made it better for me and put it to save the file to the new folder.
The problem is if i try to cange fopen first parameter to str what collect full path to new folder and file in it come to the program some Debug Assertion Failed. That error is in the same RipAudio(...) function but in fwrite function. I dont understand how my fopen- function affect with fwrite- function.
Error message gives "Expression: (stream != NULL)" message of fwrite.c. Is my getcurrentdirectory - createdirectory code right?
•
•
Join Date: Dec 2006
Posts: 7
Reputation:
Solved Threads: 0
•
•
•
•
> fp = fopen( str, "w+b" );
This (in all probability) returned NULL, which you then passed on (unchecked) to another function.
Where on receiving NULL, it asserted and told you what was wrong.
I was not sharp enough. The path build was wrong.
sprintf(str, "%s%s", str, temp); ---> sprintf(str, "%s\\%s", str, temp);
So it returns NULL to FILE.
But now it works. Thank you a lot.
![]() |
Similar Threads
- Debug Assertion Failure (Web Browsers)
- infile into array and sort (C++)
- MFC Listener (C)
- Debug Assertion Failed (Troubleshooting Dead Machines)
- Deleting a pointer? (C++)
Other Threads in the C Forum
- Previous Thread: buffer to upper case?
- Next Thread: Loading a structure (text lines) from a file, modify the structure, then save
| Thread Tools | Search this Thread |
#include * ansi array arrays asterisks binarysearch calculate centimeter changingto char character convert copyanyfile copyimagefile copypdffile creafecopyofanytypeoffileinc createprocess() database dynamic execv fflush fgets file floatingpointvalidation fork forloop function getlogicaldrivestrin givemetehcodez grade gtkwinlinux histogram homework i/o ide inches include infiniteloop input interest intmain() iso keyboard km license linked linkedlist linux list looping lowest matrix meter microsoft mysql number oddnumber open opendocumentformat openwebfoundation pdf pointer posix power probleminc process program programming pyramidusingturboccodes radix read recursion recv recvblocked research reversing scheduling segmentationfault send sequential single socket socketprogramming stack standard strchr string suggestions systemcall test threads turboc unix urboc user variable whythiscodecausesegmentationfault win32api windowsapi






