본문 바로가기

Ongoing/String

(8)
[C++ C# Python Java] String Concatenation // [C++] String Concatenation // VC : suppress error messages about obsolete & deprecated functions#pragma warning(disable : 4996)#define _CRT_SECURE_NO_WARNINGS#define _CRT_SECURE_NO_WARNINGS_GLOBALS #include #include using namespace std; int main(){ // string text0 = "Hello" + "World"; // error string text1 = "Hello" "World"; cout
[C# C++ Python] verbatim string, raw string literal [C#] verbatim stringusing System; namespace Sharp1{ class Program { static void Main(string[] args) { Console.WriteLine("c:\next\race\folder\test1.xlsx"); Console.WriteLine(@"c:\next\race\folder\test1.xlsx"); // verbatim string Console.ReadKey(); } }} [C#] interpolated stringhttps://docs.microsoft.com/en-us/dotnet/csharp/language-reference/tokens/interpolated [C#] verbatim stringhttps://docs.mic..
[C#] Composite Format String & Interpolated String 아래는 Composite Format String의 간단한 예제이다.string name = "John"; int age = 20; string gender = "male"; string phone = "012-3456-7890"; Console.WriteLine("First = {0}, Second = {1}, Third = {2}, Fourth = {3}", name, age, gender, phone);이 예제를 보면 {0} {1} {2} {3} 에 무엇이 대입될 것인지 하나씩 찾아보아야 Console.WriteLine 출력문이 이해가 된다. Console.WriteLine 출력문을 Interpolated String으로 바꾸면 아래와 같이 된다.Console.WriteLine($"First = {..
for [C/C++] char[] string #include using namespace std; int main(int argc, char **argv) { char words[] = "Hello"; for (auto t : words) { cout
for [Java] String package coffee; public class Program { public static void main(String[] args) { String words = "Java"; char[] chars = words.toCharArray(); for (char t : chars) { // Java 10: for (var t : chars) System.out.println(t); } }} /* OutputJava*/ package coffee; public class Program { public static void main(String[] args) { String words = "Java"; for (int i = 0; i < words.length(); i++) { System.out.pri..
for foreach [C#] string using System; namespace Console1{ class Program { static void Main(string[] args) { string words = "Hello"; foreach (var c in words) { Console.WriteLine(c); } } }} /* OutputHello*/ using System; namespace Console1{ class Program { static void Main(string[] args) { string words = "Hello"; for (int i = 0; i < words.Length; i++) { Console.WriteLine(words[i]); } } }} /* OutputHello*/
for [Python] string # Python 3 words = 'Python' for c in words: print(c) """ OutputPython""" # Python 3 words = 'Python' for i in range(len(words)): print(i, words[i]) """ Output0 P1 y2 t3 h4 o5 n""" # Python 3 words = 'Python' for i, c in enumerate(words): print(i, c) """ Output0 P1 y2 t3 h4 o5 n"""
IO Functions [C] Character & String // VC : suppress error messages about obsolete & deprecated functions#pragma warning(disable : 4996)#define _CRT_SECURE_NO_WARNINGS#define _CRT_SECURE_NO_WARNINGS_GLOBALS #include #define LENGTH 100 int main(){ int letter; char buffer[LENGTH]; char bumper[LENGTH]; letter = getchar(); // getchar is a wrapper function for fgetc putchar(letter); // putchar is a wrapper function for fputc letter = f..