he below code works fine with dec c++ compiler but when run on visual studio gives the error at fseek

#include<stdlib.h>
#include<stdio.h>
#include<conio.h>
int main()
{
     FILE *fp;
     char *stringBuff;
     int i;
     int epi = 0;
     long lSize;
    fopen_s (&fp, "sequence.txt" , "rb" );
     fseek (fp ,0 , SEEK_SET);
     lSize = ftell (fp);
     rewind (fp);
     stringBuff = (char*) malloc (sizeof(char)*lSize);
     fread (stringBuff,1,lSize,fp);
     for(i = 0 ; i < lSize; i++)
     epi = epi + 2 * (stringBuff[i] - 48 ) - 1;
     
     printf("%d", epi);
     getch();
     return ;
     
}
     
     

//error Native' has exited with code 3 (0x3).

What error (we can't see your screen)?

Perhaps if you added some error checking code, rather than blindly assuming that success is guaranteed, you might be able to ask a more direct question.

What error (we can't see your screen)?

Perhaps if you added some error checking code, rather than blindly assuming that success is guaranteed, you might be able to ask a more direct question.

I am sorry that i didn't tell what was the exact problem. The code i have put on the thread works fine with dav c++ compiler but when the same code is run with visual c++ it gives error with fseek saying its assertion problem please read the document of the visual studio and it crashes

Understand that failure to crash on one system is not a proof of correctness. More often than not, it just makes you lucky (not good).

The real proof comes when you start running the code through many different compilers, on many different operating systems.

Since you don't actually (still!) post any error messages, I'm going to hazard a guess that your assert says something like stream != NULL.

In which case, you FAILED to open the file, and you FAILED to check the return status.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.