Hi everyone
I want to make a quiz, I want to have to output an array of questions after a form is submitted.
I know to use a bean I think but how would I do this?
Thanks
I'm having a coloumn name with varchar field that holds some folder path like "C:\Program Files\Internet Explorer\en-US" .I need to update the root folder name(Program files to profilesNew).Can anyone please help.
I tried with a query
declare @val as varchar(100)
set @val='C:\Program Files\Internet Explorer\en-US'
select substring(@val,charindex(':\',@val),charindex('\',@val))
but not getting the exact answer
C:\Program FilesNew\Internet Explorer\en-US
I've been using C++ for quite a long time now but nevertheless I tend to fall back on scanf when I have to parse simple text files. For example given a config like this (also assuming that the order of the fields could vary):
foo: [3 4 5]
baz: 3.0
I would write something like:
char line[SOME_SIZE];
while (fgets(line, SOME_SIZE, file)) {
int x, y, z;
if (3 == sscanf(line, "foo: [%d %d %d]", &x, &y, &z)) {
continue;
}
float w;
if (1 == sscanf(line, "baz: %f", &w)) {
continue;
}
}
What's the most concise way to achieve this in C++? Whenever I try I end up with a lot of scaffolding code.
I'm reading a registry value like this:
char mydata[2048];
DWORD dataLength = sizeof(mydata);
DWORD dwType = REG_SZ;
..... open key, etc
ReqQueryValueEx(hKey, keyName, 0, &dwType, (BYTE*)mydata, &dataLength);
My problem is, that after this, mydata content looks like: [63, 00, 3A, 00, 5C, 00...], i.e. this looks like a unicode?!?!.
I need to convert this somehow to be a normal char array, without these [00], as they fail a simple logging function I have. I.e. if I call like this: WriteMessage(mydata), it outputs only "c", which is the first char in the registry. I have calls to this logging function all over the place, so I'd better of not modify it, but somehow "fix" the registry value. Here is the log function:
void Logger::WriteMessage(const char *msg)
{
time_t now = time(0);
struct tm* tm = localtime(&now);
std::ofstream logFile;
logFile.open(filename, std::ios::out | std::ios::app);
if ( logFile.is_open() )
{
logFile << tm->tm_mon << '/' << tm->tm_mday << '/' << tm->tm_year << ' ';
logFile << tm->tm_hour << ':' << tm->tm_min << ':' << tm->tm_sec << "> ";
logFile << msg << "\n";
logFile.close();
}
}
In actionscript an object's property can be accesses in this way:
object["propertyname"]
Is something like this possible in c#, without using reflection?
Hi my question
Need to get the 10 word before and 10 words after for the given text . i mean need to start the 10 words before the keyword and end with 10 word after the key word.
Given text : "Twenty-three"
The main trick : content having some html tags etc .. tags need to keep that tag with this content only . need to display the words from 10before - 10after
content is bellow :
removed
Thank you
I am trying to add a .html suffix at the end of all strings supplied by the user before it is entered into the database. Here's my code so far:
strtolower(str_replace(" ", "_", $postTitle));
The above takes the title of the post the user it trying to make, turns it to lower case, replaces all white spaces with underscores and makes it ready to be entered into a database column called post_url.
I just need it to do one more thing and that's to add a .html at the end of each post url. What is the function to do this?
Could someone take a look at this code and find out what's wrong with it?
#!/bin/sh
while :
do
echo " Select one of the following options:"
echo " d or D) Display today's date and time"
echo " l or L) List the contents of the present working directory"
echo " w or W) See who is logged in"
echo " p or P) Print the present working directory"
echo " a or A) List the contents of a specified directory"
echo " b or B) Create a backup copy of an ordinary file"
echo " q or Q) Quit this program"
echo " Enter your option and hit <Enter>: \c"
read option
case "$option" in
d|D) date
;;
l|L) ls $PWD
;;
w|w) who
;;
p|P) pwd
;;
a|A) echo "Please specify the directory and hit <Enter>: \c"
read directory
if [ "$directory = "q" -o "Q" ]
then
exit 0
fi
while [ ! -d "$directory" ]
do
echo "Usage: "$directory" must be a directory."
echo "Re-enter the directory and hit <Enter>: \c"
read directory
if [ "$directory" = "q" -o "Q" ]
then
exit 0
fi
done
printf ls "$directory"
;;
b|B) echo "Please specify the ordinary file for backup and hit <Enter>: \c"
read file
if [ "$file" = "q" -o "Q" ]
then
exit 0
fi
while [ ! -f "$file" ]
do
echo "Usage: \"$file\" must be an ordinary file."
echo "Re-enter the ordinary file for backup and hit <Enter>: \c"
read file
if [ "$file" = "q" -o "Q" ]
then
exit 0
fi
done
cp "$file" "$file.bkup"
;;
q|Q) exit 0
;;
esac
echo
done
exit 0
There are some syntax errors that I can't figure out. However I should note that on this unix system echo -e doesn't work (don't ask me why I don't know and I don't have any sort of permissions to change it and even if I wouldn't be allowed to)
Bash Shell Scripting Error: "./myDemo ./myDemo: line 62: syntax error near unexpected token done' ./myDemo: line 62: " [Edited]
EDIT: I fixed the while statement error, however now when I run the
script some things still aren't
working correctly.
It seems that in the b|B) switch statement
cp $file $file.bkup doesn't
actually copy the file to file.bkup ?
In the a|A) switch statement
ls "$directory" doesn't print the directory listing for the user to see
?
#!/bin/bash
while $TRUE
do
echo " Select one of the following options:"
echo " d or D) Display today's date and time"
echo " l or L) List the contents of the present working directory"
echo " w or W) See who is logged in"
echo " p or P) Print the present working directory"
echo " a or A) List the contents of a specified directory"
echo " b or B) Create a backup copy of an ordinary file"
echo " q or Q) Quit this program"
echo " Enter your option and hit <Enter>: \c"
read option
case "$option" in
d|D) date
;;
l|L) ls pwd
;;
w|w) who
;;
p|P) pwd
;;
a|A) echo "Please specify the directory and hit <Enter>: \c"
read directory
if [ ! -d "$directory" ]
then
while [ ! -d "$directory" ]
do
echo "Usage: "$directory" must be a directory."
echo "Specify the directory and hit <Enter>: \c"
read directory
if [ "$directory" = "q" -o "Q" ]
then
exit 0
elif [ -d "$directory" ]
then
ls "$directory"
else
continue
fi
done
fi
;;
b|B) echo "Specify the ordinary file for backup and hit <Enter>: \c"
read file
if [ ! -f "$file" ]
then
while [ ! -f "$file" ]
do
echo "Usage: "$file" must be an ordinary file."
echo "Specify the ordinary file for backup and hit <Enter>: \c"
read file
if [ "$file" = "q" -o "Q" ]
then
exit 0
elif [ -f "$file" ]
then
cp $file $file.bkup
fi
done
fi
;;
q|Q) exit 0
;;
esac
echo
done
exit 0
Another thing... is there an editor that I can use to auto-parse code? I.e something similar to NetBeans?
I'm trying to print strings in one line.
I've found solutions but they don't works with windows correctly.
I have text file contains names and I want to print them like this
name=john then change john to next name and keep name=, I've made this code but didn't work correctly with windows:
op = open('names.txt','r')
print 'name=',
for i in op.readlines():
print '\r'+i.strip('\n')
thank you for your time
Hi there,
I need to write a script that takes the current path (%~dp0), transforms backslashes into forward slashes and passes it further to some command.
Due to the environment I'm working in the only option that I have is windows shell (not Powershell where the issue would not a problem).
Is it even possible to do that?
I need to check if a key exists and return its value if it does.
Key can be an array with subkeys or endkey with a value.
$_SESSION['mainKey']['testkey'] = 'value';
var_dump(doesKeyExist('testkey'));
function doesKeyExist($where) {
$parts = explode('/',$where);
$str = '';
for($i = 0,$len = count($parts);$i<$len;$i++) {
$str .= '[\''. $parts[$i] .'\']';
}
$keycheck = '$_SESSION[\'mainKey\']' . $str;
if (isset(${$keycheck})) {
return ${$keycheck};
}
// isset($keycheck) = true, as its non-empty. actual content is not checked
// isset(${$keycheck}) = false, but should be true. ${$var} forces a evaluate content
// isset($_SESSION['mainKey']['testkey']) = true
}
What am I doing wrong ?
Using PHP 5.3.3.
My send mail task works fine for email ids like [email protected] but it throws error for email ids like [email protected].
is there any way i can make it work for such ids also?
Thanks.
A field in my table can have arbitrary strings. On the UI, there is a drop down having options like
All, Value1, Value2
And the results were filtered by the selected option value. So far this is easy and adding new filters to the UI is not a problem. Needs no changes in my stored procedure. Now I want to have an "Others" option here as well, which will return rows not having the column value as Value1 or Value2.
Apparently this will require a "not in" operator in my query, and will make maintenance difficult, as the list of values is likely to change
Any suggestions, design tips?
while(sqlite3_step(compiledStatement) == SQLITE_ROW) {
NSString *araci2 = [NSString stringWithUTF8String:(char *)sqlite3_column_text(compiledStatement, 2)];
[dbarray addObject:araci2];
NSLog(@"DB ITEMS: %@",dbarray);
}
First of all, I try to get a description longer than a line from db. While part of the value appears meaningful, some of the characters of those values are absurd like "00fu". How can I print them in proper fashion ?
Hi,
NSString *newValue = @"#xyz";
but the following searchPreidate is not finding that. pls let me know how to solve this
self.searchPredicate = [NSPredicate predicateWithFormat:@"(value contains[c] %@) OR (title contains[c] %@)",newValue, newValue];
how do you append an additional url parameter to a link in your google search results? is it possible to do this within the style sheet?
for example i have domain.com/result.htm - i want to change the link to domain.com/result.htm?param=1
thank you
Dear all,
I'm a newbie in bash and I would like to pass as parameter to a python function all files in a directory that don't match a given pattern. sth. like:
$myscripts/myprog.py $myfiles/!(bonjovi)
The above example should retrieve all files that don't match to "bonjovi".
Best wishes
I need to pass '+' via the QueryString.
some special character can be passed by using 'Encode' .. but '+'
I know the one solution, If I replace '+' with other character.
But it's not the perfect solution.
I want to write a program in C that displays each word of a whole sentence (taken as input) at a seperate line. This is what i have done so far:
void manipulate(char *buffer);
int get_words(char *buffer);
int main(){
char buff[100];
printf("sizeof %d\nstrlen %d\n", sizeof(buff), strlen(buff)); // Debugging reasons
bzero(buff, sizeof(buff));
printf("Give me the text:\n");
fgets(buff, sizeof(buff), stdin);
manipulate(buff);
return 0;
}
int get_words(char *buffer){ // Function that gets the word count, by counting the spaces.
int count;
int wordcount = 0;
char ch;
for (count = 0; count < strlen(buffer); count ++){
ch = buffer[count];
if((isblank(ch)) || (buffer[count] == '\0')){ // if the character is blank, or null byte add 1 to the wordcounter
wordcount += 1;
}
}
printf("%d\n\n", wordcount);
return wordcount;
}
void manipulate(char *buffer){
int words = get_words(buffer);
char *newbuff[words];
char *ptr;
int count = 0;
int count2 = 0;
char ch = '\n';
ptr = buffer;
bzero(newbuff, sizeof(newbuff));
for (count = 0; count < 100; count ++){
ch = buffer[count];
if (isblank(ch) || buffer[count] == '\0'){
buffer[count] = '\0';
if((newbuff[count2] = (char *)malloc(strlen(buffer))) == NULL) {
printf("MALLOC ERROR!\n");
exit(-1);
}
strcpy(newbuff[count2], ptr);
printf("\n%s\n",newbuff[count2]);
ptr = &buffer[count + 1];
count2 ++;
}
}
}
Although the output is what i want, i have really many black spaces after the final word displayed, and the malloc() returns NULL so the MALLOC ERROR! is displayed in the end.
I can understand that there is a mistake at my malloc() implementation but i do not know what it is.
Is there another more elegant - generally better way to do it?
Thanks in advance.
Is there any difference in speed/memory usage for these two equivalent expressions:
Regex.IsMatch(Message, "1000")
Vs
Message.Contains("1000")
Any situations where one is better than other ?
filtered=[]
text="any.pdf"
if "doc" and "pdf" and "xls" and "jpg" not in text:
filtered.append(text)
print(filtered)
This is my first Post in Stack Overflow, so excuse if there's something annoying in Question, The Code suppose to append text if text doesn't include any of these words:doc,pdf,xls,jpg.
It works fine if Its like:
if "doc" in text:
elif "jpg" in text:
elif "pdf" in text:
elif "xls" in text:
else:
filtered.append(text)
I have a page create-quote.aspx. I want to open this page in different modes, depending on whether a querystring parameter is present or not.
My question is at which event should I check, If I have a querystring parameter or not.
I think, it should be preinit, what do you say.
I have to create dynamically allocated array of CStatic (CStatic* array;), which then displayed on the dialog. It must be allocated and filled like this:
array = new CStatic[list_box.GetCount()];
for (int i = 0; i < list_box.GetCount(); i++) {
CString str;
list_box.GetText(i, str);
array[i].Create(str, WS_CHILD, CRect(), GetParent());
}
But str is destroyed after the dialog is closed, because list_box destroyes too, and all pointers inside CStatics points nowhere (I assume it is not working because of this). What can I do to fix this? Any help would be appreciated.
P.S. I know, that this is awful way and this is all wrong and I know how to do this right, but unfortunately, I can't change tasks, they give us in the university :)
Hi frns,
Am using the strip_tags() to remove the HTML tags from one content . but i wants to remove the html (<DIV></DIV>,<P></P>,<SAPAN></SAPAN>) tags apart from the <img> tag and <a> , i don't want to remove the <img ><a> tag from that . but need to remove other all html tags from that content how can i do help me.
thanks