Hello,
I'm learning C++ and developing a project to practice, but now i want to turn a variable(String) in code, like this, the user have a file that contains C++ code, but i want that my program reads that file and insert it into the code, like this:
#include <iostream>
#include <fstream>
#include <string>
#include <cstdlib>
using name...
I'm trying to convert the following XML into a Time:
<time hour="18" minute="05" timezone="Eastern" utc-hour="-4" utc-minute="00" />
I'm parsing the XML using SimpleXML, and storing that in a class. I also tried printing out the following:
print strtotime($x->time->attributes()->hour . ":" . $x->time->attributes()->minute) . "<br>\...
I need to slightly change a string in an exe which I dont have source code for anymore. It was writtin in C.
I notice that C string literals do not seem to appear in the machine code listing at all - not in raw ASCII anyway, not in utf8/16/32 or anything like that. They seem to be encoded, I am guessing as part of 32bit op-codes. For ex...
There doesn't seem to be a standard constructor so I've taken to doing the following
void myMethod(char delimiter = ',')
{
string delimiterString = 'x';
delimiterString[0] = delimiter;
// use string version ...
}
Is there a better way to do this?
...
I have the following code that sends a message using the mail() function. Everything works fine except the line breaks at the end of each line don't seem to work. As you can see I am using " \r\n " hoping that this will give me a line break but it doesn't I have added <br> to get the break, but I would rather not use that in case someone...
I have a set of links in header.asp which is included on every page; these links have their href attribute set to whatever the current page is plus a linkID param. Sometimes the page the link references will have query string params, but other times it won't. If the current page URL contains the linkID param already I need to replace it,...
I'm using Moq for unit tests, and I've set up an expectation like this:
myMock.Expect(w => w.MyMethod(It.IsAny<string>(),
It.IsAny<string>(),
It.IsAny<string>(),
It.IsAny<System.Exception>(), null))
.Returns(myResult);
the method it is mock...
I want to parse user input in a streamReader. My code is:
string txt = txtin.text ; //<~~ txtin is something like root:x:1:1....
using (TextReader reader = new TextReader( txt))
{
string line = "";
while ((line = reader.ReadLine()) != null)
{
string userName = line.Substring(0, line.IndexOf(':'));
}
}
I get ...
I'm working on a statistical project that involves iterating over every possible way to partition a collection of strings and running a simple calculation on each. Specifically, each possible substring has a probability associated with it, and I'm trying to get the sum across all partitions of the product of the substring probability in ...
In Java is there a way to find out if first character of a string is a number?
One way is
string.startsWith("1")
and do the above all the way till 9, but that seems very inefficient.
Edit:
After the answer, I found out a regex way to do this as well:
s.substring(0,1).matches("[0-9]")
...
I am trying to merge three fields in each line of a CSV file using Python. This would be simple, except some of the fields are surrounded by double quotes and include commas. Here is an example:
,,Joe,Smith,New Haven,CT,"Moved from Portland, CT",,goo,
Is there a simple algorithm that could merge fields 7-9 for each line in this format...
I am trying to define a function which can access variables which are in the scope of the function that is calling it.
( I am attempting to build a string formatter that is prettier than "a" + b, and more terse than String.format("a{0}",b). So I can get SF("a{b}"), and I don't know if it is possible )
so
function magic(str) {
re...
I am having some sort of problem with encoding in my ASP.NET HTTPHandler, which uploads a file. The file content is passed in a hidden form variable from a ColdFusion web page which is using something called "ToBase64".
In ColdFusion, the code used to place the file content into a form is as follows:
<cffile action="readBinary" file="#...
Hi Fellow StackOverflowers,
I am receiving a string in one of my .NET function. The string when viewed from the XML Visualizer looks like this:
- <root>
- <Table>
<ID>ABC-123</ID>
<CAT>Housekeeping</CAT>
<DATE>21-JUN-2009</DATE>
<REP_BY>John</REP_BY>
<LOCATION>Head Office</LOCATION>
</Table>
- <Table>
<ID>ABC-124</ID>
<C...
I have a string of this form
s='arbit'
string='%s hello world %s hello world %s' %(s,s,s)
All the %s in string have the same value (i.e. s).
Is there a better way of writing this? (Rather than listing out s three times)
...
Why isn't this working?
eval "$response = $ua->request($r);"
print "$@";
gives:
syntax error at (eval 8) line 1, near "="
...
Hi all,
I'm trying to call a method from a DLL written in C, from my C# application. Here is how I've implemented the call:
--> C method signature: (from a third-part company)
Int16 SSEXPORT SS_Initialize(Uint16 ServerIds[], Uint16 ServerQty, const char PTR *Binding, const char PTR *LogPath, Uint16 LogDays, Int16 LogLevel,
Uint16 MaxT...
Is it possible to output SQL query result in one string or variable? (i'm bad in php and mysql)
Let's say I have db "agents" with columns - agent_id, agent_fname, agent_lname, agent_dept.
Using this query:
$sql = SELECT a.`agent_fname` FROM agents a WHERE a.`agent_dept` = 'FCA'
I want to get a string or a variable, so I can use it in...
I have a string on which I need to do some replacements. I have a Dictionary<string, string> where I have search-replace pairs defined. I have created following extension methods to perform this operation:
public static string Replace(this string str, Dictionary<string, string> dict)
{
StringBuilder sb = new StringBuilder(str);
...
Faulty code:
pos_1 = 234
pos_n = 12890
min_width = len(str(pos_n)) # is there a better way for this?
# How can I use min_width as the minimal width of the two conversion specifiers?
# I don't understand the Python documentation on this :(
raw_str = '... from %(pos1)0*d to %(posn)0*d ...' % {'pos1':pos_1, 'posn': pos_n}
Required outpu...