cmd truncates first lines of ouput - c

I'm debugging a program that could potentially have up to 20,000 lines output. The command prompt appears to truncate and only show the last 1000 so I can't see the ouptput the program gave at the begining. How can I fix this so I can scroll all the way up to the point where I run the program? I'm using Windows 7 and Codeblocks IDE.

Run cmd (as admin), go to Properties->Layout tab and increase the Screen buffer size to what you want, and enable "Apply these properties for future windows".
Another option, just to check the output: Have it written to a file and read it later.

Related

Access watch variables from trace32 scripting language

I'd like to create a diagnosis script and would like somehow to get all the variables the user inputs in a watch window to a script. How may i access the watch variables and manipulate them?
I tried with a DIALOG.view but that wastes too much time. There might be another trace command but I don't know it. Thank you!
Getting the content of open Var.Watch windows from script is not directly supported in TRACE32.
However you can do the following in you script
Redirect printing to a file PRinTer.FILE "~~~/winpage.txt" ASCIIE (of course you can choose any other filename instead of winpage.txt)
The window WinPAGE.List shows you all open child windows. With WinPrint.WinPAGE.List you can sent the list of all open windows to the file specified before (winpage.txt).
Now parse the content of winpage.txt for the names of the windows, which are a watch windows. The window names start by default with a capital 'W' followed by three decimal digits (but can also be totally different) and are then followed by the command (in round brackets) which was used to open the windows. Compare case insensitive!
The watch windows have a command which starts with:
B::Var.Watch
B::V.Watch
B::Var.W
B::V.W
Redirect printing to a new file e.g. PRinTer.OPEN "~~~/varwatch.txt" ASCIIE
Send the content of each open watch window to the file varwatch.txt with the command WinPRT <window name>. The relevant window names you've got from step 3. Execute WinPrt for each open watch window.
Close varwatch.txt with PRinTer.CLOSE
Now you should have the content of all open watch-windows in the file varwatch.txt.
Other idea:
Use command STOre "mywindows.cmm" Win to save commands to create all open windows to a script.
Parse this script for all lines starting with Var.Watch (or one of it's shorts forms) and the lines starting with Var.AddWatch (or one of it's shorts forms). Parse case insensitive!. The arguments followed by Var.Watch or Var.AddWatch are the variables currently shown in the watch windows.

Resizing output Terminal in C Language

would like to get some help on a c project i am currently working on. I have a string/array of output to the terminal, but somehow the standard terminal is too small for my output. Even after i manually expand the window of the console the output is still cut off, instead of printing in a single line, it just gets cut off and go to the next row automatically.
hope to get help.
I think that the only way to correct this is by splitting your one-line output in multiple lines, using "\n" at the end of every line.
By doing this you can control when and where it has to write in the next line, and you can make it look more like you wanted to.

C: open second custom sized terminal and use it for output

I am writing a program in C that is started simply by the terminal. Now I want to make the program itself open another terminal with a custom size and write its output in there.
I found the command
system("gnome-terminal");
which opens another terminal, but I can't find a function that lets me write into this second terminal. I am using Ubuntu.
If you have any idea, that would be great
The easiest thing would probably be to write the output to a file, say /tmp/tmp96888 (tip: mkstemp) and then do something like
system("gnome-terminal --geometry=40x14 --command 'less /tmp/tmp96888'");
Or, to update continuously from the file:
system("gnome-terminal --geometry=40x14 --command 'tail -f /tmp/tmp96888'");
But if you can, I think the best way is to open a new terminal and run the program itself in it, and just print the output. It's only if you actually need to do things in the original window that you have to bother with a separate output window.

Ubuntu terminal not displaying all values

I have a C program that displays all the possibilities of the letters "A-B-C-D-E-F" can make. That comes to 720 possibilities. But my terminal is only displaying 511 possibilities. I tried looking online on how to edit terminal settings and found this following and did them. I went into edit>profile preferences and selected "use custom terminal size" and set both the values for rows and columns to 800. Sadly only 511 continues to display.
Can someone please tell me what is the solution to this, im really puzzled.
PS: Every entry is on its own line. For example:
ABCDEF
ABDCEF
......
......
In addition to less described by David Grayson, you should also be familiar with redirection:
my_program > outputfile.out
This creates a new file (or overwrites an existing one) with the output from your program. Now you can open the file in a text editor to look at the output. You can also use the wc utility to count the number of lines:
wc outputfile.out
If you only want to check that your program creates the correct amount of output, you can use the following pipe:
my_program | wc
You need to go to the Scrolling tab and set the number of lines in scroll buffer to something higher than 512.
Another useful utility to know about is less. You can pipe the output of your program into it and it lets you scroll around and search through the output:
my_program | less
I think you want to see all the output answers.you can see the answer from "answer" after you execute the program like a.out>answer.
now open the file(answer),you will see the result.
">" is a operator

What are possible reasons that cmd stop writing to a file with redirection?

This is on win7.
I got a batch script that executes a C++ program and take all of its output to the file with ">".
The program takes input from servers and display everything. We need all these information so we log all these outputs down to a file. But after a short while, we see that the program stops writing to the file and just stop there while the program continues running.
The file size is also at 0 byte (OS doesn't update until file is closed?) But we can see the content of the file with notepad++, but it does not seem to update any longer.
There are about 250,000 lines long and we see that our data simply got cut off in the end. For example, suppose you should have a table of data that lists out 123 567 436 975, we only see 123 567 43. The whole line isn't even finished in the end.
There are a lot of things to write down and there are lots of network transmission. Does the program simply give up outputting when there are too much data? Is there a way around this?
Try to disable buffering. setbuf(stdout, NULL);.
Anyway, in new versions of windows, when a file is being created and data is being written (the clasic >file scenario), the grow of the file is not always visible.
In this case, dir command shows a 0 bytes file, or stops to show increasing values.
Try to read the file with type file >nul and then dir file. This "should" refresh the file size information. But it is not needed. The file is growing, just not showing it.

Resources