computing
  • 0

C++ system() and variables?

  • 0

Hello, i’m just messing around right now in C++ and i’m trying to make my own little “search” utility b/c the one in windows xp is horribly slow and i’ve found with a batch file you can find the location of something like 100x faster then windows search can. so now i’m just trying to write a little program that will be more flexible then going into a batch file and changing a file name every time i want to find something 🙂 however, for this i need to take in a variable and then include that in the system() command as the string. but i’m not sure how i’d do this.. as of now i tried:

system(“dir /s /b | find /i “” << strng << “” > “c:shibbyfoundfile.shibby””);

but Dev-C++ tells me: “error: invalid
operands of types `const char[22]’ and `char[50]’ to binary `operator<<‘
” (i hope that displays properly. we’ll see in a minute.. but yea, does anyone know how i’d accomplish this task?

Share

0 Answers

  1. yea so i figured out it would be easier to just have the program create a batch file and put the string into that, then run the batch file through the program. once its done searching, it deletes the batch file. so NOW, how do i make the program return to the main menu? because i was once told by someone that you shouldn’t directly call the main() function from another function.. and he produced a file that would do this very thing. but he used a switch and bool statement in it and i can make switch statements (i used one in this file) but i’m not positive how to make it produce this same result and unluckily, i dont still have this file 🙁

    • 0