Why isn't my terminal running my updated C++ code? - c++

I am a new programmer and I am trying to use the terminal on my Mac to compile and run the C++ code I write using the Sublime text editor.
I am able to get my code to run using the terminal, however, whenever I make changes to my code on sublime and then re-compile it on my terminal, my terminal doesn't recognize my changes and keeps on running my original code.
Does anyone know what might be happening?
Thank you so much!

I can think of two possibilities that spring immediately to mind. If you're changing your code in the editor, and that's not being reflected in the compilation, then it's likely to be one of the following. Either:
you're not saving the file in the location you think you are; or
you're not saving the file at all.
The easiest way to tell if one of these is the case is to introduce an error into your code(a), like:
int my hovercraft = full of eels;
and make sure the compiler complains about it.
If you're not saving it at all, do so. If you're saving it in the wrong place, you can usually find out where just by doing a Save As and seeing where the default location is.
If you're annoyed that you have to save, and that computers should just "work"(b), Sublime Text has an auto-save feature that may come in handy, courtesy of one Lucy Bain. Instructions (paraphrased) are duplicated here in case that site ever disappears:
Open Sublime
Find Settings and edit the user window (under Sublime Text 2 > Preferences for Mac, just Preferences for Windows).
Add the line "save_on_focus_lost": true.
Save and close the file.
At that point, whenever you click away from a particular file, it should save it.
(a) Some developers seem to have little trouble doing this without even trying :-)
(b) A not unreasonable expectation for a Mac user :-)

Related

.How do you create a new file in Ocaml and where does it store it?

I can't seem to find the answer, how do you create a new file in Ocaml? Do you edit your file in the terminal? Where does the source code appear?
I think you're asking how to write code in OCaml, i.e., how to create an OCaml source file. (This isn't completely clear. You could be asking how to write OCaml code that creates a file.)
The details of creating OCaml source depend on your development environment, not on the language itself. So there is no one answer.
The general answer is that you can use any tool you like that knows how to create a text file. If you like working from the command line (as I do) you can work in a terminal environment and run some kind of vintage text editor from the last millennium (as I do). If you like a GUI environment, you can run some kind of "programmer's editor" from the current millennium, or really any kind of editor that creates basic utf-8 files (or even ASCII files).
Generally the editor will have to be told where to store the files that you edit. You would probably want to make some kind of folder for the project and make sure you store the text files in there.
I hope this helps! If you have any programmers nearby, they can probably get you started a lot faster than asking on StackOverflow.

Netbeans - copy highlighted regex search results

I made a simple regex search in Netbeans 7.3 on Windows (using Ctrl+F):
\{\{.*?\}\}
The results get highlighted correctly and the question is - how to extract highlighted text search results? Let it be copying to clipboard, saving as file or whatever else.
Is there any method doing this?
Maybe someone has any suggestion of alternative quick approach to such task in Netbeans? (or other editor)
What OS are you running? If OS X or Linux, read on!
I'm not sure about automatically copying the highlighted results to the clipboard, but I do workaround this quite a bit as well.
The easiest way to accomplish this for me without leaving NetBeans is to simply open a built in terminal window through Window>Output>Terminal (in 7.2.1) - I then navigate to my project, and run the RegEx that I built in the Find feature with my tool of choice. In fact, I use the built in terminal for this type of quick stuff in NetBeans quite a bit. If running Linux, using clipboard tools like xsel (http://linux.die.net/man/1/xsel) in combination with a built in terminal emulator can allow for devising some nice workflow shortcuts within IDEs if you are more comfortable working/coding at a terminal. Note that built in terminal emulators like the one in NetBeans is likely not going to play nicely with cut/copy/paste using the mouse, for various reasons that I won't get in to here.
As far as a built in/extension based solution for something like this, it would be helpful! I am not aware of one.
Hope this workaround helps in the meantime.

Prompt for saving Normal.dot

I've been experiencing some issues when trying to manually close a Word document created from my VBA project (actually developed with Access 2003). Depending on the method I use, it may prompt for saving Normal.dot and then tell me that it's already opened or being used. This is a little bit annoying, because I'm then unable to close Microsoft Word. A big waste of time.
Some frustration later, I found a little trick to solve my issue. I've decided to post it there because I've been unable to find any information about this problem on Stack Overflow.
Here's how it goes:
Set WordApplication = CreateObject("Word.Application")
WordApplication.NormalTemplate.Saved = True
Nothing really fancy here, but the second line prevents the prompt for saving Normal.dot. It does NOT actually save anything to the template, it just let MS-Word believe it's been already saved.
Be sure that the option to prompt for saving Normal.dot is disabled in your MS Word's Preferences (Tools > Preferences > Save > Prompt to save Normal template). Disabling so will prevent the prompt in normal use situations. However, there might be some issue like the one above when you're creating a document from scratch with VBA (and probably many other languages), always depending on the method you implement to create/open your document.
Hopefully this little line will save you some more minutes of research.

How to keep the terminal from scrolling

I am writing a simple program in C++ to be run in a terminal window. I would like the output text to be locked in position on the screen. Instead of each new line appearing at the bottom of the screen and pushing everything up, I would like to be able to change a line of text or some characters in a line of text, while keeping other lines above and below it static. I know I have seen this done in terminal, and I believe it was done with C++, but I can't find any documentation on it. I cannot even think of what this type of display might be called. My google fu has failed me; please help. If you can tell me what commands/library to use, that would be great, but even being able to tell me what commands accomplish this in a programming language other than C++ would give me more to go on than I have now.
You want ncurses, a library for displaying text on a terminal.
If you are programming for Microsoft Windows, try googling for Win32 Console Functions.

Django -editing files in bash

I just installed Django on my Mac and I am trying to figure out a way to edit the python modules directly from the terminal.
I know I can view the contents of a file using the less command in the command line, but is there a way I can edit Django modules from the command line, as well? It's just kind of annoying having to switch between the command line and a text editor, so I was hoping I could do everything in one spot.
Thanks,
Jerry
EDIT: rephrased.
There are lots of TUI text editors available for *nix. vim and emacs are popular, and are available in several forms for OS X.
This question is a little confused.
There's no such thing as "editing in Python", or "editing in Bash". I don't know what you're regarding as the "Python" that you have to switch to, but most people using a Mac edit their Python files in something like Textmate. That can be always running, and the Django development server automatically reloads when you save changes to any of the files in use, so this is the often most convenient way of doing it.
Bash is the shell that runs inside the terminal. Instead of talking about "editing in Bash", I expect you mean "editing in the terminal". Of course, there are hundreds of editors that run inside the terminal. One that comes installed on the Mac is vim, which I use all the time - but it has its fair share of idiosyncrasies, and takes a lot of getting used to.
However, if anything, editing in vim inside the terminal seems like it would involve more "switching" rather than less. You'd either need to have a separate terminal tab, and switch between the one running the server and the one running vim, or continually quit your server to go into vim.