Click here to Skip to main content
15,559,644 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
im trying to run programme but instead of output im getting following error, now little bit i know that its connected to a path but dont know how to solve it as im new to programming.


Sanjana@SanjanaPC MINGW64 /d/DSA/sorting
$ cd "d:\DSA\sorting\" && g++ Bubble_sort.cpp -o Bubble_sort && "d:\DSA\sorting\"Bubble_sort
bash: cd: d:\DSA\sorting" && g++ Bubble_sort.cpp -o Bubble_sort && d:DSAsorting"Bubble_sort: No such file or directory       

Sanjana@SanjanaPC MINGW64 /d/DSA/sorting
$


What I have tried:

I have watched every youtube video and tried every suggestion in the comments, yet nothing has seemed to fix it. TBH most of the solution i didnt understand.
Posted
Updated 10-Jan-22 7:35am
v2
Comments
Richard Deeming 10-Jan-22 12:23pm    
I suspect the quotes on the final command:
"d:\DSA\sorting\"Bubble_sortd:DSAsorting"Bubble_sort: No such file or directory

Try taking the quotes out:
cd "d:\DSA\sorting\" && g++ Bubble_sort.cpp -o Bubble_sort && d:\DSA\sorting\Bubble_sort

or wrapping the entire path in quotes:
cd "d:\DSA\sorting\" && g++ Bubble_sort.cpp -o Bubble_sort && "d:\DSA\sorting\Bubble_sort"

1 solution

It looks like you might be running bash under mingw or mayby cygwin on windows, so this is tailored to that assumption. For starters, I don't think you need to change directory to <cod>d:\DSA\sorting, since that's where you already appear to be based on your prompt. So you should just be able to do g++ Bubble_sort.cpp - o Bubble.sort && ./Bubblesort. Given your environment, I think you should be able to use Unix style path separators (/) rather than the window style (\) at your command promp.

Supposing that your environment knows how to deal with cd "d:\DSA\sorting\", why do you get an error message? That's because in bash, strings in double quotes get escape expansion - e.g. "hello\nworld" gets expanded to
hello
world
Note that the \n in the string got turned into a newline character.So in your case the string "d:\DSA\sorting\" is seen as an unterminated string, since the sequence \" is treated as an an embedded quote mark. The final \ is not necessary, so you could instead use cd "d:\DSA\sorting", or use a single-quoted string, which does not get escape expanded e.g. <ode>cd 'd:\DSA\sorting\'
 
Share this answer
 
v4

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900