Difference between \\n and \\r?

Difference between \\n and \\r?

What’s the difference between \n (newline) and \r (carriage return)?In particular, are there any practical differences between \n and \r? Are there places where one should be used instead of the other? 1:In terms of ascii code, it's 3 --

C: differences between char pointer and array [duplicate]

C: differences between char pointer and array [duplicate]

This question already has an answer here: Why do I get a segmentation fault when writing to a string initialized with “char *s” but not “char s[]”? 16 answers

Parsing CSV files in C#, with header

Parsing CSV files in C#, with header

Is there a default/official/recommended way to parse CSV files in C#? I don't want to roll my own parser.Also, I've seen instances of people using ODBC/OLE DB to read CSV via the Text driver, and a lot of people discourage this due to its "

Insert into … values ( SELECT … FROM … )

Insert into … values ( SELECT … FROM … )

I am trying to INSERT INTO a table using the input from another table. Although this is entirely feasible for many database engines, I always seem to struggle to remember the correct syntax for the SQL engine of the day (MySQL, Oracle, SQL

How do I get a YouTube video thumbnail from the YouTube API?

How do I get a YouTube video thumbnail from the YouTube API?

If I have a YouTube video URL, is there any way to use PHP and cURL to get the associated thumbnail from the YouTube API? 1:Each YouTube video has 4 generated images. They are predictably formatted as follows:https://img.youtube.com/vi/<

What does “use strict” do in JavaScript, and what is the reasoning behind it?

What does “use strict” do in JavaScript, and what is the reasoning behind it?

Recently, I ran some of my JavaScript code through Crockford's JSLint, and it gave the following error: Problem at line 1 character 1: Missing "use strict" statement.Doing some searching, I realized that some people add "use strict"; into

Rails 4: how to use $(document).ready() with turbo-links

Rails 4: how to use $(document).ready() with turbo-links

I ran into an issue in my Rails 4 app while trying to organize JS files "the rails way". They were previously scattered across different views. I organized them into separate files and compile them with the assets pipeline. However, I just

How do I shuffle an array in Swift?

How do I shuffle an array in Swift?

How do I randomize or shuffle the elements within an array in Swift? For example, if my array consists of 52 playing cards, I want to shuffle the array in order to shuffle the deck. 1:This answer details how to add a fast and uniform (Fi

Command not found error in Bash variable assignment

Command not found error in Bash variable assignment

I have this script called test.sh:#!/bin/bashSTR = "Hello World"echo $STRwhen I run sh test.sh I get this:test.sh: line 2: STR: command not foundWhat am I doing wrong? I look at extremely basic/beginners bash scripting tutorials online and

Quickly reading very large tables as dataframes in R

Quickly reading very large tables as dataframes in R

I have very large tables (30 million rows) that I would like to load as a dataframes in R. read.table() has a lot of convenient features, but it seems like there is a lot of logic in the implementation that would slow things down. In my c

How do I use shell variables in an awk script?

How do I use shell variables in an awk script?

I found some ways to pass external shell variables to an awk script, but I'm confused about ' and ".First, I tried with a shell script:$ v=123test$ echo $v123test$ echo "$v"123testThen tried awk:$ awk 'BEGIN{print "'$v'"}'$ 123test$ awk 'BE

When is JavaScript's eval() not evil?

When is JavaScript's eval() not evil?

I'm writing some JavaScript code to parse user-entered functions (for spreadsheet-like functionality). Having parsed the formula I could convert it into JavaScript and run eval() on it to yield the result.However, I've always shied away fro

JavaScript post request like a form submit

JavaScript post request like a form submit

I'm trying to direct a browser to a different page. If I wanted a GET request, I might saydocument.location.href = 'http://example.com/q=a';But the resource I'm trying to access won't respond properly unless I use a POST request. If this we

How to use a variable for a key in a JavaScript object literal?

How to use a variable for a key in a JavaScript object literal?

Why does the following work?.stop().animate( { 'top' : 10 }, 10);Whereas this doesn't work:var thetop = 'top';.stop().animate( { thetop : 10 }, 10);To make it even clearer: At the moment I'm not able to pass a CS

How to concatenate text from multiple rows into a single text string in SQL server?

How to concatenate text from multiple rows into a single text string in SQL server?

Consider a database table holding names, with three rows:PeterPaulMaryIs there an easy way to turn this into a single string of Peter, Paul, Mary? 1:I had a similar issue when I was trying to join two tables with one-to-many relationship

Generate random numbers replicating arbitrary distribution

Generate random numbers replicating arbitrary distribution

I have data wherein I have a variable z that contains around 4000 values (from 0.0 to 1.0) for which the histogram looks like this. Now I need to generate a random variable, call it random_z which should replicate the above distribution. Wh

In PHP, how can I add an object element to an array?

In PHP, how can I add an object element to an array?

I'm using PHP. I have an array of objects, and would like to add an object to the end of it.$myArray[] = null; //adds an element$myArray[count($myArray) - 1]->name = "my name"; //modifies the element I just addedThe above is functional, but

How do I fill a va_list

How do I fill a va_list

If I have a va_list I know how to extract all its elements: void printInts(int n,...){ va_list va; va_start(va, n); for(unsigned int i=0; iSo when I call printInts(3,1,2,3) the va_list get filled of all the parameters.But how do I

Can an XOR linked list be implemented in C++ without causing undefined behavior?

Can an XOR linked list be implemented in C++ without causing undefined behavior?

An XOR linked list is a modified version of a normal doubly-linked list in which each node stores just one "pointer" instead of two. That "pointer" is composed of the XOR of the next and previous pointers. To traverse the list, two pointe

Unit Test with Mongoose

Unit Test with Mongoose

I'm new to Node.js, Mongoose, and testing in this environment. I have the following schema declared in a separate file. Issue = mongoose.model("Issue", { identifier: String, date: String, url: String, name: String, thumbnai

Recursively finding only directories with FileUtils.listFiles

Recursively finding only directories with FileUtils.listFiles

I want to collect a list of all files under a directory, in particular including subdirectories. I like not doing things myself, so I'm using FileUtils.listFiles from Apache Commons IO. So I have something like:import java.io.File;import ja

Type.GetProperties() missing in Xamarin PCL

Type.GetProperties() missing in Xamarin PCL

In Xamarin PCL, I'm trying to get the System.Reflection.PropertyInfo of a class I've written so that I can access its properties by their string name to get/set, and Type.GetTypeInfo() is missing, as well as Type.GetProperties. But System.R

Read speed of SharedPreferences

Read speed of SharedPreferences

How fast are SharedPreferences? Is there a way to put them in memory for reading? I have a small amount of data that a ListView has to query to display each cell, and I'm worried that a call to flash memory will be too slow. I'm not worr

DialogFragment in Android with theme

DialogFragment in Android with theme

I'm building my first app in android. I've made a dialogFragment, but it doesn't look nice enough.For having a style and a theme I used this setStyle(DialogFragment.STYLE_NORMAL,0). What I want is that the edge of the fragment to be black l

how to overwrite data in a txt file? [duplicate]

how to overwrite data in a txt file? [duplicate]

Possible Duplicate: Can any one tell why the previous data is still displayed while saving data using StreamWriter I have WPF C# application, that reads and writes to a .txt file, i know how to write line but line, but how do I overwrite