在{之前预期的未经资格的id

时间:2016-10-03 20:31:13

标签: c++ assembly

我试图在inLine程序集中编写一个开放系统调用。我读到了删除;是我的问题。但我试图调用open系统调用并设置fd,我的文件描述符,等于那个,而不是声明一个函数。

#include "syscall.hh"
#include <stdio.h>
#include <string.h>  
#include <stdlib.h>


int main(int argc, const char* argv[])
{

    char *buffer;
    int i = 0;
    int n = 0;
    int woc = 100;
    int loopCnt; 
    int inBufferSize = 0;
    int fd;

    if (argc != 3)
    {
        printf("Usage: cp file1 file2");
        return 1;
    }
      /////***this is the line where i believe my issue is***///
    fd = open(argv[2], O_WRONLY | O_CREAT, 0644);
    if (fd == -1)
    {
        perror("open");
        return 3;
    }
    //end if

    if (argc > 0)
    {
        inBufferSize = atoi(argv[1]);
        printf("inBufferSize = '%i' \n", inBufferSize);
    }
    //end if 


    buffer = new char[inBufferSize];
    for (i = 0; i < inBufferSize; i++)
    {
        buffer[i] = 'a';
    }
    //end for

    fd = 0;

    loopCnt = (woc / inBufferSize); 
    for (n = 0; n <= loopCnt; n++)
    {
        my_write(fd, buffer, inBufferSize);
    }
    //end for


    return 0;
}

0 个答案:

没有答案