0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

指定した値を返却するだけのモックプログラム

Posted at

指定した値を返却するだけのモック

一応、Windows/Linux両方対応。

mock.sh
#include <stdio.h>
#include <string.h>
#include <unistd.h>

#define SIZE 255

int main(int argc, char** argv){
    // init.
    int i;
    FILE *file;
    char configFilePath[ SIZE ];
    memset(configFilePath, 0, sizeof(configFilePath));

    // get String of Config-file path.
    char* dir_end=NULL;
    // linux case.
    dir_end = strrchr(argv[0], '/');
    if (dir_end == NULL){
        // windows case.
        dir_end = strrchr(argv[0], '\\');
        if (dir_end == NULL){
            return 1;
        }
    }
    strncpy(configFilePath, argv[0], (dir_end - argv[0])+1);
    strcat(configFilePath, "val.config");

    // file read.
    file = fopen(configFilePath, "r");
    fscanf(file, "%d", &i);
    fclose(file);
    sleep(1);
    printf("%d\n", i);
    return i;
}
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?