0

My professor has given us a program that we must fill in the blanks of missing functions, and then once complete, turn this finished project .c file in as our final project for the class.

Problem is, she has included escape sequences in her code, which I cannot get to work(like all the other students in the class).

My visual studio 2010 will run the program, but the output looks ridiculous and jumbled. A few sequences she uses are...

printf( "\033[2J"); //clear screen

printf( "\033[s");//save cursor position

printf( "\033[3;1H");//go to line 3 

She has given us directions to run ansi160\x64, and I have tried running this and researching this for 4 hours now(I was up late last night) and could not get this to work. No matter what extension I used, it's location, etc. So simply, I need to have my ouput window on visual studio to read these escape sequences so I can debug my program and see it's output window via a window that will allow me to read escape sequences.

Edit: I'm on a Mac, with bootcamp, and partitioned to run Windows 7(if this matters).

  • 3
    The Windows console window can't handle many [VT100 escape codes](http://www.termsys.demon.co.uk/vtansi.htm), which is what those are. You might want to research corresponding [Windows console functions](http://msdn.microsoft.com/en-us/library/windows/desktop/ms682073%28v=vs.85%29.aspx). – Some programmer dude Apr 27 '13 at 15:30
  • Okay. But how are all the other students getting this to work? The department wouldn't allow her to post this program, if there wasn't a way to get this to work. I know other people have gotten ansicon to work, but I cannot. This is my problem. – idle_engineer Apr 27 '13 at 15:32
  • Maybe you can ask them? – Some programmer dude Apr 27 '13 at 15:33
  • I did. No such luck yet. – idle_engineer Apr 27 '13 at 15:34
  • Aren't you allowed to *ask your professor for help*? – autistic Apr 27 '13 at 15:37
  • @user44063 Please forgive me for the seemingly off-topic question, but what class is this? Joachim Pileborg seems to have the best answer here to me, I only know these as "linux terminal" escape codes and have no knowledge of them working on windows at all. Perhaps via the "Windows console functions" linked above – Daniel Santos Apr 27 '13 at 15:44
  • This is a 200 level c-programming course. She gave basic directions including "hit start menu, then type cmd, then ansi160\x64, then -i" which does nothing for me. She doesn't know to fix this... is what I'm guessing. She is a grad student only. – idle_engineer Apr 27 '13 at 15:46
  • Are you allowed to use windows functions for those escape sequences? – Binayaka Chakraborty Apr 27 '13 at 19:22

1 Answers1

0

its a linux escape sequence, install a free linux in a virtualbox(some may even advise to uninstall windows as a joke, or not)... it takes under 2 hours and 8gb of space.

Also you can use an online javascript linux using vi (the compiler is called tcc there, but it works the same way) http://bellard.org/jslinux/

In addition, you can install cygwin in under 10 minutes which I believe also supports this escape sequence.

Dmytro
  • 5,068
  • 4
  • 39
  • 50
  • No other students were required to download and run Linux. So this isn't an option. – idle_engineer Apr 27 '13 at 15:35
  • Why was this downvoted, I provided a full solution to getting the program to work, the only thing I left out is installing cygwin, which takes about 10 minutes. edit: I included cygwin as well. – Dmytro Apr 27 '13 at 15:38
  • No. I need a windows application emulator that attaches to visual studio. – idle_engineer Apr 27 '13 at 15:38
  • Is that one of the project requirements? Please define "windows application emulator" and "attaches to visual studio". – autistic Apr 27 '13 at 15:39
  • Sounds sketchy, talk to your professor. PS: downvoting people for no reason is evil. – Dmytro Apr 27 '13 at 15:40
  • @Dmitry upvoting just because you linked jslinux, lol! Seriously user44063, if she didn't define the parameters of where this had to work, it is indeed a *real* option! jslinux was written by this inanely brilliant man who implemented a *real* x86 virtual machine in ECMAScript (a.k.a. "JavaScript"). – Daniel Santos Apr 27 '13 at 15:43
  • Can I not use a console emulator? Console2, ConEMU, and have Visual Studio run in that instead of the windows console? – idle_engineer Apr 27 '13 at 15:48
  • You might, you'd need an emulator that supports them, and I don't even know if or how to attach... It's not realistically practical neither, since you can just use Windows API for that stuff... – Dmytro Apr 27 '13 at 15:52
  • You can try http://stackoverflow.com/questions/12602411/use-custom-console-for-visual-studio-console-application-debugging – Dmytro Apr 27 '13 at 15:53
  • Although I doubt your escape sequence will even compile properly under windows... I actually am pretty certain C will just turn \0 into NUL effectively ruining your string... – Dmytro Apr 27 '13 at 15:55
  • @Dmitry No, an octal escape sequence extends as far as possible, so `\033` is one character, that's specified by the standard (although that admittedly doesn't guarantee that every implementations adheres to it). – Daniel Fischer Apr 27 '13 at 16:06
  • Sounds right, although it's still not going to extend over the whole thing, I will just call it undefined behavior. – Dmytro Apr 27 '13 at 16:09
  • No, all the strings are fine. If the terminal doesn't understand the escape sequences, the output will be gibberish, but no undefined behaviour here. – Daniel Fischer Apr 27 '13 at 16:19
  • dmitry How do I run my .c file in that linux link? – idle_engineer Apr 27 '13 at 16:45
  • tcc FILE.c -o FILE, then ./FILE, I assume you know how to use vi to type the code. – Dmytro Apr 27 '13 at 17:05
  • Don't make any assumptions to my abilities. All I know how to do is type the .c file... hit debug in VS, and hope it compiles. – idle_engineer Apr 27 '13 at 17:06
  • If you are not expected to learn linux, then you should ask your professor in person what he is asking, it is really hard to solve a problem which you do not understand. All I can say is that I have ran the code given on CentOS on my VirtualBox and it works fine. I tried it in the link I gave, it ignores those escape sequences (better than undefined behavior). Your best option is either talk to your professor, or install Linux and try to figure it out yourself. Both options beat trying to solve a problem which you do not understand. – Dmytro Apr 27 '13 at 17:12