output

prevent terminal output in LISP

情到浓时终转凉″ 提交于 2019-12-11 01:59:40
问题 I want to run a function but not have it output the result in the terminal. For example, (set 'A 'B) normally returns B in the console like the following: >>> (set 'A 'B) B >>> A B I don't want it to return anything; I still want the function to do what it's supposed to, just silently: >>> (set 'A 'B) >>> A B 回答1: It's not perfect, but you can use (values) at the end of your expression to suppress output. You get a blank line instead. Common Lisp: (progn (set 'A 'B) (values)) I'm not sure of

How to Align text to the right using cout?

ⅰ亾dé卋堺 提交于 2019-12-11 01:52:51
问题 Suppose I have a string s which is given below: string s="i am\ngoing\nto\ncuet"; I want to align the string to the right during display in console. So I want to show output like this: EDIT: rightmost characters should be aligned. i am going to cuet I tried this code to show the output: cout.width(75); cout<<s; But it only right align the first line like this: i am going to cuet Then I tried this code to get the output: for(int i=0 ; i<s.size(); i++) { cout.width(75); cout<<s[i]; } But I get

Powershell Add-Content Truncating Output

半世苍凉 提交于 2019-12-11 01:46:08
问题 I'm using the Add-Content cmdlet in a PowerShell script to write the matches in a foreach loop to a separate text file. To do this, I'm using the following code: Add-Content -Path $varListNotFound $match The $varListNotFound contains the file name and path while the $match is the variable in the foreach loop that is being matched in my range of items. I'm not sure if it makes a difference, but the matches I'm matching are being pulled from an XML document. In the output text file, the matches

Telling nohup to write output in real-time

帅比萌擦擦* 提交于 2019-12-11 01:02:21
问题 When using nohup the output of a script is buffered and only gets dumped to the log file (nohup.out) after the script has finished executing. It would be really useful to see the script output in something close to real-time, to know how it is progressing. Is there a way to make nohup write the output whenever it is produced by the script? Or, since such frequent file access operations are slow, to dump the output periodically during execution? 回答1: There's a special program for this:

How to keep user's input printed?

柔情痞子 提交于 2019-12-11 00:23:36
问题 I'm trying to add a comments from user, so I just tried to read the input and send it to print it , but the problem is that the printed input disappears as soon as I refresh the page or enter another input. so I want to keep all user's appearing always even when refreshing the page or re-entering a new comment. code : <div> <input type="text" name="comments" placeholder = "Your comment goes here .. " class = "sug-box" id = "UserComment"> <button class = "send-box" onclick="go()">Add</button>

Moving std::clog in source to output file [duplicate]

て烟熏妆下的殇ゞ 提交于 2019-12-10 23:02:55
问题 This question already has answers here : What is the point of clog? (5 answers) Closed 3 years ago . I have a basic debug message in my code that prints a message as to what function is called. #ifdef _DEBUG std::clog << "message etc" << std::endl; #endif How do I redirect the output to send the message to a textfile? 回答1: You can set the buffer associated with clog that uses a file to save its data to. Here's a simple program that demonstrates the concept. #include <iostream> #include

C++ program stops producing console output upon input to the console

限于喜欢 提交于 2019-12-10 18:35:20
问题 I have a C++ program (MSVC 2017) which constantly outputs debug information via std::cout. However sometimes when I physically interact with the console (e.g. click on it accidentally) it stops producing output. Meaning that there's just nothing being printed, although the program continues to run and finishes doing whatever it's doing correctly. Any ideas how to fix this? Removing std::cout buffer with "std::cout.setf(std::ios::unitbuf);" has no effect. Sample: #include <iostream> int main()

How do I get the output from Database.ExecuteNonQuery?

我们两清 提交于 2019-12-10 15:58:13
问题 I would like to use the Database.ExecuteNonQuery or something similar to execute a sql script and then capture the output. eg: xxx Table created My script: strArray = Regex.Split(streamReader.ReadToEnd(), "\r\nGO"); if (connection.State == ConnectionState.Open) { System.Data.SqlClient.SqlCommand cmd; foreach (string sql in strArray) { cmd = new System.Data.SqlClient.SqlCommand(sql); cmd.Connection = connection; Console.WriteLine(sql); Console.WriteLine(cmd.ExecuteNonQuery().ToString()); } }

Explanation for this function's output

不打扰是莪最后的温柔 提交于 2019-12-10 14:21:56
问题 I am doing review questions which ask me "What is the output of the following," and I am having some trouble understanding something about this function: int a = 1, b = 1, c = -1; c = --a && b++; printf("%d %d %d", a, b, c); The output is 010. My question is about line 2, c = --a && b++ . How is this line processed, and how does it work/change the values? And if it were c = --a || b++ ? From my understanding I thought the output would be 020. 回答1: The key concept to understanding the result

PHP: How to delete all array elements after an index [duplicate]

本秂侑毒 提交于 2019-12-10 13:38:23
问题 This question already has answers here : php - how to remove all elements of an array after one specified (3 answers) Closed 5 years ago . Is it possible to delete all array elements after an index? $myArrayInit = array(1=>red, 30=>orange, 25=>velvet, 45=>pink); now some "magic" $myArray = delIndex(30, $myArrayInit); to get $myArray = array(1=>red, 30=>orange); due to the keys in $myArray are not successive, I don't see a chance for array_slice() Please note : Keys have to be preserved! + I