| | |
Debug assertion failed problem
Please support our C advertiser: Programming Forums - DaniWeb Sister Site
![]() |
•
•
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
Views: 1014 | Replies: 2
| Thread Tools | Search this Thread |
Tag cloud for C
adobe ansi api array arrays bash binarysearch centimeter char convert copyanyfile copypdffile cprogramme createcopyoffile createprocess() csyntax directory drawing dynamic executable fflush file fork frequency getlasterror givemetehcodez global graphics gtkgcurlcompiling hardware highest homework i/o inches infiniteloop initialization interest km lazy linked linkedlist linux linuxsegmentationfault list locate logical_drives match matrix meter microsoft motherboard multi mysql open opendocumentformat opensource openwebfoundation owf pattern pdf performance pointer pointers posix power problem probleminc program programming pyramidusingturboccodes read recursion recv repetition scanf scheduling segmentationfault send shape socketprograming spoonfeeding stack standard strchr string strings structures student suggestions system systemcall test testautomation unix user voidmain() wab win32 win32api windows.h






