开发者

UNIX - syntax error in my main

Im getting a syntax error in the following main statement...

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

The error says "syntax error near unexpected token `('".

However, as you can see, there are the right amount of parentheses there. What's the issue?

Thanks!

More code:

/*Core Dump Program*/

#include <stdio.h>
#include <sys/resource.h>
#include <stdlib.h>
#include <errno.h>


int main (int argc, char *argv[])
 {
  struct rlimit limit;

  limit.rlim_cur = 0;
  limit.rlim_max = 0;
  if (setrlimit(RLIMIT_CORE, &limit) == -1){
    printf("Error preventing core dump errno=%d\n", errno);
    exit(10);
  }
  else {
    printf("The current core limit is %llu\n", limit.rlim_cur);
    printf("The core max limit is %llu\n", limit.rlim_max);
    exit(0);
  }
  if (getrlimit(RLIMIT_FSIZE, &limit) == -1){
    printf("getlimit() failed with errno=%d\n", errno);
    exit(1);
  }
  else {
    printf("The current core limit is %llu\n", limit.rlim_cur);
    printf("The core max limit is %llu\n", limit.rlim_max);
    exit(0);

  }
  if (getrlimit(RLIMIT_CPU, &limit) == -1){
    exit(1);
  }
  else {
    printf("The current core limit is %llu\n", limit.rlim_cur);
    printf("The core max limit is %llu\n", limit.rlim_max);
    exit(0);
  }

  if (getrlimit(RLIMIT_NOFILE, &limit) == -1){
      printf("Error preventing core dump errno=%d\n", errno);
      exit(1);
    }
  else {
      printf("The current core limit is %llu\n", limit.rlim_cur);
      printf("The core max开发者_如何学JAVA limit is %llu\n", limit.rlim_max);
      exit(0);
  }

  if (getrlimit(RLIMIT_NPROC, &limit) == -1){
    printf("Error preventing core dump errno=%d\n", errno);
    exit(1);
  }
  else {
    printf("The current core limit is %llu\n", limit.rlim_cur);
    printf("The core max limit is %llu\n", limit.rlim_max);
    exit(0);

  }
  }


check your code for "invisible" characters. Depending on how the file was created, it's possible to get control characters and/or unicode chars that you can't see in your normal text editor's normal operating mode. Many editors have a "Show Invisible Characters" feature (or something similarly named). Some editors even have a feature that will find and remove any such chars (e.g. "Zap Gremlins" in Text Wrangler for OS-X.


The last time I got an error like that its because something contains a special character. Sometimes, when you copy stuff of the web there are characters that the compiler doesn't recognize.

If you are using an IDE I would recommend checking the syntax highlighting and seeing if there is anything odd, such as the quotes don't cause a different color, and replace them.

More info:

http://support.microsoft.com/kb/887842

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜