string

Reverse a sentence in C??

Hi, I had just written a programme which reverses a sentence whatever the user gives. for eg:If the user gives the sentence as "How are you",my programm generates "uoy era woH". The programme which i had written is shown below.I just have a wild intution that there can be a smarter programe than the one which i had written.So valuab...

How to check the length of an input? (C++)

I have a program that allows the user to enter a level number, and then it plays that level: char lvlinput[4]; std::cin.getline(lvlinput, 4) char param_str[20] = "levelplayer.exe " strcat_s(param_str, 20, lvlinput); system(param_str); And the level data is stored in folders \001, \002, \003, etc., etc. However, I have no way of tellin...

Ruby cross-platform way to write the EOF symbol

Hey, Is there a platform-independent way of writing the EOF symbol to a string in Ruby. In *nix I believe the symbol is ^D, but in Windows is ^Z, that's why I ask. Cheers Pete ...

wchar_t vs wint_t

Hello. This is an ANSI C question. I have the following code. #include <stdio.h> #include <locale.h> #include <wchar.h> int main() { if (!setlocale(LC_CTYPE, "")) { printf( "Can't set the specified locale! " "Check LANG, LC_CTYPE, LC_ALL.\n"); return -1; } wint_t c; while((c=getwc(stdin))!=...

Why does .NET create new substrings instead of pointing into existing strings?

From a brief look using Reflector, it looks like String.Substring() allocates memory for each substring. Am I correct that this is the case? I thought that wouldn't be necessary since strings are immutable. My underlying goal was to create a IEnumerable<string> Split(this String, Char) extension method that allocates no additional me...

String to TStream

I'm attempting to convert a string to a TStream. My code below gives me an "Abstract Error" message on the CopyFrom line. I'm against a brick wall here, any ideas on how to solve this? procedure StringToStream(const AString: string; out AStream: TStream); var SS: TStringStream; begin SS := TStringStream.Create(AString); try ...

how to implement strlen() in c#?

I was thinking to a solution to calculate length of string in c# without using Length property. I thing which I can think of is getting this done is Program is in C# public static int strlen (string s) { string temp = s + '/0'; char [] c = temp.ToCharArray(); int length = 0; while (c[length]!='/0'...

convert string to datetime in ado.net

I am trying to save data into my database using a vb form. I am using a datetimepicker to insert the date into my database. Here's an example saveCommand.Parameters.AddWithValue("A_BOOKDATE", abookdatePicker1.Text).DbType = DbType.DateTime In my database i set its attribute to time ,now the thing is i used the same line of code on anot...

can Flex return a string match to bison

I'm writing a Bison/Flex program to convert LaTeX into MathML. At the moment, dealing with functions (i.e. \sqrt, \frac, etc) works like this, with a token for every function \\frac {return FUNC_FRAC;} and passes the token FUNC_FRAC back to bison, which plays its part in the description of this subtree: function: FUNC_FRAC L...

Is there a strtol equivalent that does not require a null-terminated string?

Hi, Is there a standard C function similar to strtol which will take a char* and a length for a non-null-terminated string? I know that I could copy out the string into a null-terminated region, but for efficiency reasons that is undesirable. Thanks. ...

String.Format against string.Format. Any issues?

Hi. Is there any performance differences between string.Format and String.Format ? As far as i understand string is a shortcut for System.String and there's no difference between them. Am i right? Thanks! ...

String to object in JS

I have a string as string = "firstName:name1, lastName:last1"; now I need one object obj such that obj = {firstName:name1, lastName:last1} How can I do this in JS? ...

ClassName to class_name

Hi, I'm sure this is an easy one for you geeks: Say I have a String "ThisIsMyString" and I want to format it like "this_is_my_string" using Ruby. How do I do that? Matt ...

How do I create an array of strings in C?

I am trying to create an array of strings in C. If I use this code: char (*a[2])[14]; a[0]="blah"; a[1]="hmm"; gcc gives me "warning: assignment from incompatible pointer type". What is the correct way to do this? edit: I am curious why this should give a compiler warning since if I do printf(a[1]);, it correctly prints "hmm". ...

NSString newbie question about setting a char from it.

Ok, I know this is a very basic question, but my head is swimming in NSString vs C string nonsense. Basically I have a NSString the just contain 1 character for example the letter D How do I take that 1 character NSString and assign it to a variable of char So I have... char mychar; NSString *myMode = [[NSString alloc] initWithFo...

Asking for opinion for my MenuTree structure. Which is better, array or delimiter approach?

Which is the better API? I think the latter approach is better because strings are interned. But I'm pining for succintness. Which do you think is better? [Task("Assortment", Author = "好先生", MenuTree = "The>Quick>Brown>Megan")] public partial class Form1 : MycForm, ITaskPlugin { } or this(strings can be interned): [Task("As...

Is it good practice to use java.lang.String.intern()?

The Javadoc about String.intern() doesn't give much detail. (In a nutshell: It returns a canonical representation of the string, allowing interned strings to be compared using ==) When would I use this function in favor to String.equals()? Are there side effects not mentioned in the Javadoc, i.e. more or less optimization by the JIT co...

C# Can't get String to DateTime conversion to work

Hi, I've done some simple string -> DateTime conversions before using DateTime.ParseExact(), but I have a string that I can't seem to get parsed properly. I'm probably doing something very obvious wrong but I just can't see what it is. The code is as follows: string date = "Tue Jun 23, 2009 2:23 pm"; DateTime lastupdate = DateTime.Par...

PHP, why sometimes "\n or \r" works but sometimes doesnt??

Well, I am abit confuse using these \r,\n,\t etc things. Because I read online (php.net), it seems like works, but i try it, here is my simple code: <?php $str = "My name is jingle \n\r"; $str2 = "I am a boy"; echo $str . $str2; ?> But the outcome is "My name is jingle I am a boy" Either I put the \r\n in the var or i...

AssertContains on strings in jUnit

Is there a nicer way to write in jUnit String x = "foo bar"; Assert.assertTrue(x.contains("foo")); ...