bad ptr on fopen in visual studio C

Discussion in 'Software' started by longbowrocks, May 3, 2010.

  1. longbowrocks

    longbowrocks Private E-2

    Here's a program in C that I've been working on. The important parts are highlighted.
    I've tried both fopen, and fopen_s, and they both give me <bad ptr> when I debug. Can anyone help?

    void main(){
    struct node** primes; //linked list of all primes found so far
    int current; //value currently being checked for prime

    FILE* fp = NULL;
    fp = fopen("primes.txt", "r+");
    primes = NULL;
    current = 3;

    if(fp == NULL){
    printf("No saved progress found.\nTime to kick *** and take primes.\n");
    fp = fopen("primes.txt", "w+");
    primes = addVal(&fp, 2, primes);
    }
    else{
    printf("Saved progress found.\nLoading file to continue previous progress.\n");
    initList(&fp, primes);
    }

    while(1){
    primes = check(&fp, current, primes);
    current += 2;
    }

    fclose(fp);
    return;
    }
     
    Last edited: May 3, 2010
  2. longbowrocks

    longbowrocks Private E-2

    Ok, nevermind. C is stupid, but apparently <Bad Ptr> can mean it works fine. It's just that when you first open a file, some things haven't been initialized.
     

MajorGeeks.Com Menu

Downloads All In One Tweaks \ Android \ Anti-Malware \ Anti-Virus \ Appearance \ Backup \ Browsers \ CD\DVD\Blu-Ray \ Covert Ops \ Drive Utilities \ Drivers \ Graphics \ Internet Tools \ Multimedia \ Networking \ Office Tools \ PC Games \ System Tools \ Mac/Apple/Ipad Downloads

Other News: Top Downloads \ News (Tech) \ Off Base (Other Websites News) \ Way Off Base (Offbeat Stories and Pics)

Social: Facebook \ YouTube \ Twitter \ Tumblr \ Pintrest \ RSS Feeds