Search Results

Search found 35302 results on 1413 pages for 'string literals'.

Page 168/1413 | < Previous Page | 164 165 166 167 168 169 170 171 172 173 174 175  | Next Page >

  • What is the safest way to pass strings around in C?

    - by chucknelson
    I have a program in C using Solaris with VERY ancient compatibility it seems. Many examples, even here on SO, don't work, as well as lots of code I've written on Mac OS X. So when using very strict C, what is the safest way to pass strings? I'm currently using char pointers all over the place, due to what I thought was simplicity. So I have functions that return char*, I'm passing char* to them, etc. I'm already seeing strange behavior, like a char* I passed having its value right when I enter a function, and then the value being mysteriously gone OR corrupted/overwritten after something simple like one printf() or an malloc to some other pointer. I was thinking maybe declaring a local char[] inside each function, using strcpy() immediately, and then eventually returning a pointer where char *returnval = strdup(localchar[]); This seems...sloppy. Can anyone point me in the right direction on a simple requirement?

    Read the article

  • How to remove the file extension in a zsh completion?

    - by meeselet
    I want to adjust zsh so that I can tab complete: myprog <tab> using all *.foo files in ~/somedir, but have it so that it displays them without the .foo extension. Is there any way to do this? This is what I have so far: #compdef myprog typeset -A opt_args local context state line local -a mydirs mydirs="(. ~/somedir)" _arguments -s -S \ "*:name:->foos" \ && return 0 case $state in (foos) _files -W ${mydirs} -g '*.foo(:r)' && return 0 ;; esac return 1 However, this displays double the output for every file (that is, each .foo file is listed with and without its extension). Is there any way around this?

    Read the article

  • Exploding a String In PHP

    - by streetparade
    How do i explode this string '||25||34||73||94||116||128' i need to have a array like this array ( 0 => '25', 1 => '34', 2 => '73', 3 => '94', 4 => '116', 5 => '128' ) explode("||", $array); didnt work for me i get this array array ( 0 => '', 1 => '25', 2 => '34', 3 => '73', 4 => '94', 5 => '116', 6 => '128', )

    Read the article

  • C++ visitor pattern handling templated string types?

    - by Steve the Plant
    I'm trying to use the visitor pattern to serialize the contents of objects. However one snag I'm hitting is when I'm visiting strings. My strings are of a templated type, similar to STL's basic_string. So something like: basic_string<char_type, memory_allocator, other_possible_stuff> \\ many variations possible! Since I can have very many different templated string types, I can't go and add them to my visitor interface. It would be ridiculous. But I can't add templates to my VisitString method because C++ prevents using templates parameters in virtual methods. So what are my options to work around this?

    Read the article

  • Powershell's import-clixml from string

    - by rocku
    Is there any way to run import-clixml cmdlet on a string or xml object? It requires a file path as input to produce ps objects and can't get input from an xml object. Since there is convertto-xml cmdlet which serializes ps object into xml object, why isn't there a convertfrom-xml, which would do the opposite? I am aware of System.Xml.Serialization.XmlSerializer class which would do just that, however I would like to stick with cmdlets to do this. Is there any way to do this with cmdlets (probably just with import-clixml), without creating temporary files?

    Read the article

  • mysqli real_escape_string problem

    - by tridat
    When im inserting to the database on my dev server the text goes in fine, for example "that's" is "that's" in the db. when uploading the exact same code to production server (hosted on a reseller account at bluehost) "that's" becomes "that\'s", im not double escaping, its exactly the same code, what could be the issue here?

    Read the article

  • Can't append to array using string field name [$] when performing update on array fields

    - by Haraldo
    rowsI am attempting to perform a mongodb update on each field in an array of records. An example schema is below: { "_id" : ObjectId("508710f16dc636ec07000022"), "summary" : "", "uid" : "ABCDEF", "username" : "bigcheese", "name" : "Name of this document", "status_id" : 0, "rows" : [ { "score" : 12, "status_id" : 0, "uid" : 1 }, { "score" : 51, "status_id" : 0, "uid" : 2 } ] } So far I have been able to perform single updates like this: db.mycollection.update({"uid":"ABCDEF","rows.uid":1}, {$set:{"rows.$.status_id":1}},false,false) However, I am struggling as to how to perform an update that will update all array records to a status_id of 1 (for instance). Below is how I imagine it should work: db.mycollection.update({"uid":"ABCDEF"}, {$set:{"rows.$.status_id":1}},false,true) However I get the error: can't append to array using string field name [$] I have tried for quite a while with no luck. Any pointers?

    Read the article

  • String.fromCharCode & CharacterSets

    - by jAndy
    Hi Folks, I recently tried to mirror some input within input(text) fields. Using String.fromCharCode(event.which) for instance, translates all 'standard' characters correctly. Well it translates them all to uppercase, but that you can easily catch by looking up the shift key aswell. My Problem is, it can't translate characters like dots, commas, questionmarks etc. First guess was that I have to define a character encoding set, but that does not seem to help. Maybe it'm completly off? Kind Regards --Andy

    Read the article

  • I'm looking for a constraint to prevent the insert of an empty string in MySQL

    - by Marga Keuvelaar
    Ok, in this question I learned how to prevent the insert of a NULL value. But, unfortunately, an empty string is being inserted anyway. Apart from preventing this on the PHP side, I'd like to use something like a database constraint to prevent this. Of course a check on the application side is necessary, but I'd like it to be on both sides. I am taught that whatever application is talking to your database, it should not be able to insert basically wrong data in it. So... CREATE TABLE IF NOT EXISTS tblFoo ( foo_id int(11) NOT NULL AUTO_INCREMENT, foo_test varchar(50) NOT NULL, PRIMARY KEY (foo_id) ); Would still allow me to do this insert: INSERT INTO tblFoo (foo_test) VALUES (''); Which I would like to prevent.

    Read the article

  • Sending an array of complex objects in the get string in C# ASP.NET MVC

    - by Mr Snuffle
    Hi, I want to send an array of objects in the get request string. I know this isn't the optimal solution, but I really just want to get this up and running. If I have a class, something like this public class Data { public int a { get; set; } public int b { get; set; } } public class RequestViewData { public IList<Data> MyData { get; set; } } I thought I could bind the MVC route to a web request like this http://localhost:8080/Request?MyData[0].a=1&MyData[0].b=2&MyData[1].a=3&[MyData[1].b=4 But all this does is create an array of two data objects without populating the values 1,2, 3 or 4. Is there a way to bind complex objects arrays?

    Read the article

  • Overloading operator>> for case insensitive string

    - by TheSOFan
    Given the definition of ci_string from cpp.reference.com, how would we go about implementing operator? My attempts at it involved std::read, but it doesn't seem to work (that is, gcount() properly counts the number of characters entered, but there is no output) #include <iostream> #include <cctype> #include <string> // ci_string definition goes here std::istream& operator>>(std::istream& in, ci_string& str) { return in.read(&*str.begin(), 4); } int main() { ci_string test_str; std::cin >> test_str; std::cout << test_str; return 0; }

    Read the article

  • Using strtok() in a loop in C?

    - by Alex Xander
    I am trying to use strtok() in nested loop. But this is not giving me desired results. Possibly because they are using same memory location. My code is of the form:- char *token1 = strtok(Str1, "%"); while(token1 != NULL ) { char *token2 = strtok(Str2, "%"); while(token2 != NULL ) { //DO SMTHING token2 = strtok(NULL, "%"); } token1 = strtok(NULL, "%"); // Do something more }

    Read the article

  • Non-string role names in ASP.NET MVC?

    - by MikeWyatt
    ASP.NET MVC has good support for role-based security, but the usage of strings as role names is maddening, simply because they cannot be strongly-typed as enumerations. For example, I have an "Admin" role in my app. The "Admin" string will now exist in the Authorize attribute of my action, in my master page (for hiding a tab), in my database (for defining the roles available to each user), and any other place in my code or view files where I need to perform special logic for admin or non-admin users. Is there a better solution, short of writing my own authorization attribute and filter, that would perhaps deal with a collection of enumeration values?

    Read the article

  • php - get content from second pair of quotes in string

    - by Aaron Turecki
    I'm trying to get the contents of the second quotes and only the second quotes from a string. Right now I'm able to get the contents of all three quotes. What am I doing wrong? Is it possible to just print the second value in the output array? Text 2014-06-02 11:48:41.519 -0700 Information 94 NICOLE Client "[WebDirect] (207.230.229.204) [207.230.229.204]" opening database "FMServer_Sample" as "Admin". PHP if (preg_match_all('~(["\'])([^"\']+)\1~', $line, $matches)) $database_names = $matches[2]; print_r($database); Output [WebDirect] (207.230.229.204) [207.230.229.204], FMServer_Sample, Admin

    Read the article

  • Apache rewrite_mod: RewriteRule path and query string

    - by 1ace
    I currently have a website with a standard web interface on index.php, and I made an iPhone-friendly version in iphone.php. Both pages handle the same arguments. It works fine when I manually go to .../iphone.php, but I'd like to rewrite anything on .../path/ and .../path/index.php to iphone.php if %{HTTP_USER_AGENT} contains mobile, and optionally add the query string (not sure if/when I'd need to add it). So far, this is what I have in my .../path/.htaccess: RewriteEngine On RewriteCond %{HTTP_USER_AGENT} ^.+mobile.+$ [NC] RewriteRule index.php?(.*) iphone.php?$1 [L] RewriteRule index.php iphone.php [L] The problems are, it matches index.php in any subfolder, and it won't match .../path/?args… Special thanks to anyone who can correct/simplify/optimize anything =)

    Read the article

  • Rename files and directories using substitution and variables

    - by rednectar
    I have found several similar questions that have solutions, except they don't involve variables. I have a particular pattern in a tree of files and directories - the pattern is the word TEMPLATE. I want a script file to rename all of the files and directories by replacing the word TEMPLATE with some other name that is contained in the variable ${newName} If I knew that the value of ${newName} was say "Fred lives here", then the command find . -name '*TEMPLATE*' -exec bash -c 'mv "$0" "${0/TEMPLATE/Fred lives here}"' {} \; will do the job However, if my script is: newName="Fred lives here" find . -name '*TEMPLATE*' -exec bash -c 'mv "$0" "${0/TEMPLATE/${newName}}"' {} \; then the word TEMPLATE is replaced by null rather than "Fred lives here" I need the "" around $0 because there are spaces in the path name, so I can't do something like: find . -name '*TEMPLATE*' -exec bash -c 'mv "$0" "${0/TEMPLATE/"${newName}"}"' {} \; Can anyone help me get this script to work so that all files and directories that contain the word TEMPLATE have TEMPLATE replaced by whatever the value of ${newName} is eg, if newName="A different name" and a I had directory of /foo/bar/some TEMPLATE directory/with files then the directory would be renamed to /foo/bar/some A different name directory/with files and a file called some TEMPLATE file would be renamed to some A different name file

    Read the article

  • Regex to get rid of everything past the first sentence in a string in php

    - by andufo
    I need to get rid of everything after the first dot (if there is more than 1 sentence), but at the same time, cases like e.g. have to be omited. Some line e.g., when people do something. Extra content. Some line (some parenthesis). Extra content. I need to get rid of the "Extra content.". The returning value should be: Some line e.g., when people do something. Some line (some parenthesis). So far I've come with this regex taken from other threads, but it only finds the dots and split the string into an array. preg_replace('/(?<!\.)\.(?!(\s|$|\,|\w\.))/','',$text); Any ideas? Thanks.

    Read the article

  • Use stringWithFormat: as a file path in cocoa

    - by Cam
    Hello, I'm having a problem with a cocoa application that takes the value of a text field, and writes it to a file. The file path is made using stringWithFormat: to combine 2 strings. For some reason it will not create the file and the console says nothing. Here is my code: //Get the values of the text field NSString *fileName = [fileNameTextField stringValue]; NSString *username = [usernameTextField stringValue]; //Use stringWithFormat: to create the file path NSString *filePath = [NSString stringWithFormat:@"~/Library/Application Support/Test/%@.txt", fileName]; //Write the username to filePath [username writeToFile:filePath atomically:YES]; Thanks for any help

    Read the article

  • Python unicode search not giving correct answer

    - by user1318912
    I am trying to search hindi words contained one line per file in file-1 and find them in lines in file-2. I have to print the line numbers with the number of words found. This is the code: import codecs hypernyms = codecs.open("hindi_hypernym.txt", "r", "utf-8").readlines() words = codecs.open("hypernyms_en2hi.txt", "r", "utf-8").readlines() count_arr = [] for counter, line in enumerate(hypernyms): count_arr.append(0) for word in words: if line.find(word) >=0: count_arr[counter] +=1 for iterator, count in enumerate(count_arr): if count>0: print iterator, ' ', count This is finding some words, but ignoring some others The input files are: File-1: ???? ??????? File-2: ???????, ????-???? ?????-???, ?????-???, ?????_???, ?????_??? ????_????, ????-????, ???????_???? ????-???? This gives output: 0 1 3 1 Clearly, it is ignoring ??????? and searching for ???? only. I have tried with other inputs as well. It only searches for one word. Any idea how to correct this?

    Read the article

  • How to remove all special characters from URL?

    - by NeoNmaN
    Hello all. I have my class public function convert( $title ) { $nameout = strtolower( $title ); $nameout = str_replace(' ', '-', $nameout ); $nameout = str_replace('.', '', $nameout); $nameout = str_replace('æ', 'ae', $nameout); $nameout = str_replace('ø', 'oe', $nameout); $nameout = str_replace('å', 'aa', $nameout); $nameout = str_replace('(', '', $nameout); $nameout = str_replace(')', '', $nameout); $nameout = preg_replace("[^a-z0-9-]", "", $nameout); return $nameout; } BUt I can't get it to work when I use special characters like ö and ü and other, can sombody help me here? I use PHP 5.3.

    Read the article

  • Java - converting String in array to double

    - by cc0
    I'm stuck with this pretty silly thing; I got a textfile like this; Hello::140.0::Bye I split it into a string array using; LS = line.split("::"); Then I try to convert the array values containing the number to a double, like this; Double number = Double.parseDouble(LS[1]); But I get the following error message; Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 1 Does anyone have any idea why this doesn't work?

    Read the article

< Previous Page | 164 165 166 167 168 169 170 171 172 173 174 175  | Next Page >