(c++) cat exists in a different directory than expected

I’m stuck on Stage #MG5.

cat utility exists under /bin and not in /usr/bin in my local.

Here are my logs:

remote: [your-program] $ type cat
remote: [your-program] cat: not found
remote: [tester::#MG5] Output does not match expected value.
remote: [tester::#MG5] Expected: "cat is /usr/bin/cat"
remote: [tester::#MG5] Received: "cat: not found"
remote: [your-program] $ 
remote: [tester::#MG5] Assertion failed.
remote: [tester::#MG5] Test failed

And here’s a snippet of my code that returns the path of the file:

string get_path(string& file_name, string& path_env) {
  string dir, abs_path;
  stringstream ss(path_env);

  while (getline(ss, dir, ':')) {
    abs_path = dir + '/' + file_name;
    ifstream file(file_name);
    if (file.good()) return abs_path;
  }
  return "";
}

Thanks for helping out.

Hi @ImVis10, the bug is here:

By the way, cat can be located at different paths on different systems. Let me know if you’d like further assistance!

Closing this thread due to inactivity. If you still need assistance, feel free to reopen or start a new discussion!

This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.