string

Using printf with a non-null terminated string

Suppose you have a string which is NOT null terminated and you know its exact size, so how can you print that string with printf in C? I recall such method but I can not find out know... ...

Remove unallowed character from specific pattern in the php

I have a text field in which user can enter any character he/she wants. But in server i have a string patter [a-z0-9][a-z0-9+.-]*, if any of the character in the value from the text box doesn't match the pattern, then i must remove that character from that string. How can i do that in php. is there any functions for that? Thanks in adva...

Strange string behaviour with dll call

Hi. I have a Delphi 2007 Program, which calls a Delphi 2010 DLL. The Program is big and not yet ported to 2010, so there is no way i can change this right now. I use SimpleShareMem Unit to pass strings but also tried ShareMem with borlndmm.dll. For one function i now pass a string from the Delphi 2007 programm to the dll (Therefore An...

Displaying a string while using cond in Lisp

Hi, I'm just starting off with Lisp and need some help. This is technically homework, but I gave it a try and am getting somewhat what I wanted: (defun speed (kmp) (cond ((> kmp 100) "Fast") ((< kmp 40) "Slow") (t "Average"))) However, if I run the program it displays "Average" instead of just Ave...

What is equivalent in JavaScript to C#'s @ language feature for ignoring escape chars in string literals?

I think this question may be fairly evident from the title alone: I am a C# developer who often uses @ before a string literal to make it more readable (e.g. string drive = @"C:\") I am in the process of scripting out a lot of my processes (using the wonderful V8 for .Net) and I am wondering whether there's a similar feature in JavaScri...

How does String.Contains work?

Possible Duplicate: What algorithm .Net use for searching a pattern in a string? I have a loop in my program that gets a line from a file. Then there is a check to whether the line contains a string if(line.Contains("String")) { //Do other stuff } There are over 2 million rows in the file so if I can quicken the speed b...

Sybase, execute string as sql query

In Sybase SQL, I would like to execute a String containing SQL. I would expect something like this to work declare @exec_str char(100) select @exec_str = "select 1" execute @exec_str go from the documentation of the exec command execute | exec is used to execute a stored procedure or an extended stored procedur...

Why is sizeof(string) == 32 ?

What is the overhead in the string structure that causes sizeof() to be 32 ? ...

String comparison in dotnet framework 4

Hi all, I explain my problem and interrogation (excuse my bad english), i have a dotnet exe which every milliseconds past to processing is very important. This program do lot's of string comparison (most of it is "string1.IndexOf(string2, StringComparison.OrdinalIgnoreCase")) When i switch in framework 4 my program time is twice than...

Why doesn't strncpy work with a string allocated with malloc?

char* temp; temp = (char*) malloc (strlen(window->entry.value)+1); //strncpy( temp, window->entry.value, sizeof(temp) ); DOESN"T WORK memcpy (temp, window->entry.value, strlen(window->entry.value) + 1); //WORKS (where window->entry.value is a string.) Thanks. ...

Suggestions to improve a C ReplaceString function?

Hi, I've just started to get in to C programming and would appreciate criticism on my ReplaceString function. It seems pretty fast (it doesn't allocate any memory other than one malloc for the result string) but it seems awfully verbose and I know it could be done better. Example usage: printf("New string: %s\n", ReplaceString("great",...

using local variable in another button

There's an error: "The type being set is not compatible with the value representation of the tag." string fi = null; public void reading(object sender, EventArgs e) { read_from_folder = folderBrowserDialog1.ShowDialog(); if (read_from_folder == DialogResult.OK) { files_in_folder = Di...

How would I replace the character in this example using strchr?

/* strchr example */ #include <stdio.h> #include <string.h> int main () { char str[] = "This is a sample string"; char * pch; printf ("Looking for the 's' character in \"%s\"...\n",str); pch=strchr(str,'s'); while (pch!=NULL) { printf ("found at %d\n",pch-str+1); pch=strchr(pch+1,'s'); } return 0; } How would I...

Passing const char* as template argument

Why can't you pass literal strings in here? I made it work with a very slight workaround. template<const char* ptr> struct lols { lols() : i(ptr) {} std::string i; }; class file { public: static const char arg[]; }; decltype(file::arg) file::arg = __FILE__; // Getting the right type declaration for this was irritating, so I ...

PHP - add/remove carriage returns to a base 64 encoded string

Hi I have a verrrrrrrry long base64 encoded string which is displayed in a textarea. The problem is that this string doesn't have any spaces or carriage returns so it gets displayed on one line with a ugly horizontal scroll bar. Can I add somehow carriage returns manually after base64_encode() and before output to the textarea, then re...

P/Invoke C# struct with strings to C void*

I'm having a problem creating a C# P/invoke wrapper around a third party C library. In particular, the library has a method with the signature int command(SomeHandle *handle, int commandNum, void *data, int datasize); It is a wildcard method that does different things depending on commandNum. data can be a pointer to anything, like a s...

NSData to Java String

Hello all, I've been writing a Web Application recently that interacts with iPhones. The iPhone iphone will actually send information to the server in the form of a plist. So it's not uncommon to see something like... <key>RandomData</key> <data>UW31vrxbUTl07PaDRDEln3EWTLojFFmsm7YuRAscirI=</data> Now I know this data is hashed/encryp...

Shortest way to break-up long string (add whitespace) after 60 chars?

I'm processing a bunch of strings and displaying them on a web page. Unfortunately if a string contains a word that is longer than 60 chars it makes my design implode. Therefore i'm looking for the easiest, most efficient way to add a whitespace after every 60 chars without whitespaces in a string in python. I only came up with clunk...

How to take whole Html /xhtml file in single string to write ?

I am new in c# , i just want to know is it possible to take whole html document in a single string. i even want to write it in another file. Thanx in advance. ...

String array problem when getfile() returns no matches

Hi, I've been tasked to code a little app in c# which searches a directory for a given filetype. I am testing with .txt files, but the app is intended for .epl files for Zebra printers. I am trying to write it in such a way that: aO If .epl file is found, send to Printer, delete .epl file then wait a few seconds. Search directory agai...