skip to Main Content

screenshot

In the beginning, I was working on my code and I use to run a piece of code at random and suddenly I found that the was a kind of FATAL Error compiler showing in the terminal and I used to search on web, later on my fried told me to not put any space in the name of project. In the meanwhile, our discussing turned into something else because of no valid reason for the logic that he presented.

Kindly anyone with appropriate logic.

the relative error

2

Answers


  1. Not an expert but this is my thought regarding this issue.

    In shell/command line, every word acts as an input or option passed to the command. So if your file has space in name it basically becomes 2 different inputs. adjacency and matrix. Most compilation would include some sort of execution like that and so will throw and error.

    Login or Signup to reply.
  2. It is possible to have spaces in file and directory names, but you need to handle them in command lines. There are two ways of doing this:

    1. Put the whole filename withing single or double quotes:
    g++ 'adjacency matrix.cpp' -o adj
    
    1. Escape the space with backslash:
    g++ adjacency matrix.cpp -o adj
    

    Without doing this, the shell will pass ‘adjency’ and ‘matrix.cpp’ as two separate arguments to g++ which in total will get four arguments: ‘adjency’, ‘matrix.cpp’, ‘-o’, ‘adj’.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search