I wrote a code to read files
What is wrong in the following code I am always getting last filename if I print any arrayItem
#include <stdio.h>
#include <string.h>
char **get_files()
{
FILE *fp;
int status;
char file[1000];
char **files = NULL;
int i = 0;
/* Open the command for reading. */
fp = popen("ls"...
I'm doing a
System.Text.Encoding.UTF8.GetBytes(s)
on a string in two different programs (one console, one web) using .NET 2.0 framework and the encoding is coming back different from the two. For the string "everything" I get the same result, but for the string "OnI3UwUc" I get two different results.
For The "OnI3UwUc", 6f6e69337577...
Hi,
I'm using str_replace and it's not working correctly.
I have a text area, which input is sent with a form. When the data is received by the server, I want to change the new lines to ",".
$teams = $_GET["teams"];
$teams = str_replace("\n",",",$teams);
echo $teams;
Strangely, I receive the following result
Chelsea
,real
,Barcelon...
Is there any String replacement mechanism in Java, where I can pass objects with a text, and it replaces the string as it occurs.
For example, the text is :
Hello ${user.name},
Welcome to ${site.name}.
The objects I have are "user" and "site". I want to replace the strings given inside ${} with its equivalent values from the obje...
I use the == in the code below and prints out "Equals!", why? Can someone explain why these two different strings a and b are equal?
public class test
{
public static void main()
{
String a = "boy";
String b = "boy";
if(a == b)
{
System.out.println("Equals!");
}
else
...
I am calling a login script on the server using http call from iphone.
the script returns a string "Invalid" or "valid" based on given username/pswd.
Here is what I am using:
NSString *myurlstr = [[NSString alloc] initWithFormat:@"http://www.mysite.com/iph/login.aspx?username=%@&password=%@",uname,pswd];
NSString *resultstr = [NS...
Why is string a reference type, even though it's normally primitive data type such as int, float, or double.
...
is it possible to have a string value in string.xml of the sort " some string PLACEHOLDER1 some more string" so that the place holders can be assigned the value at run time.
...
I am trying to find out filetypes using c code, here is the code
char *get_file_type(char *path, char *filename)
{
FILE *fp;
char command[100];
char file_details[100];
char *filetype;
sprintf(command, "file -i %s%s", path, filename);
fp = popen(command, "r");
if (fp == NULL) {
printf("Failed to run c...
I'm kinda' new to python, but I have already written many programs including some like download-managers, games and text-editors which require a lot of string manipulation.
For representing a string literal I use either single or double inverted commas.. whichever comes to my mind first at that time.
Although I haven't yet faced any tro...
I am using the official JSON library for my java project ad i have noticed something weird.
If i have a json such as this:
{
"text": "This is a multiline\n text"
}
And i try to get the string like this:
System.out.println(jsonObject.getString("text"));
I get this on the output:
This is a multiline\n text
Instead of :
This is...
Is it possible to change strings (content and size) in Lua bytecode so that it will still be correct?
It's about translating strings in Lua bytecode. Of course, not every language has the same size for each word...
...
I have a string
var s1 = "a,$,b,c";
I want to check if another string ends with s1
So if I send these strings it has to return true
w,w,a,$,b,c
^,^,^,$,@,#,%,$,$,a,$,b,c
a,w,e,q,r,f,z,x,c,v,z,$,W,a,$,b,c
And for these false
a,$,b,c,F,W
a,$,b,c,W
a,$,b,c,$,^,\,/
How can I check it?
...
For those of you not familiar with interpolation search, it is method to search for a value in a sorted array that is potentially faster than binary search. You look at the first and last element and (assuming that the contents of the array are uniformly distributed) linearly interpolate to predict the location.
For example: we have an ...
getting error:
An error has occurred. See error log for more details.
java.lang.NullPointerException
when I attempt to edit this file in my eclipse Android sdk project.
Not seeing anything in LogCat or the Console.
I need to update this file to rename the Project.
...
Hi,
I am using a constant NEWS_POST_NUMBER and i am getting confused on how to attach it to a string to query it to database. i tried many things and it is giving errors.
here is the string i tried.
$query = "
SELECT news.id, news.timestamp, news.title
FROM news
ORDER BY id DESC
LIMIT $from, NEWS_POST_NUMBER";
please note NEWS_PO...
Note: I do NOT want to use any framework.
The goal is just to create a function that will return an element based on an HTML string.
Assume a simple HTML Document like such:
<html>
<head></head>
<body>
</body>
</html>
All functions mentioned are in included the head section and all DOM creation/manipulation is done at the end of ...
i have a bunch of strings
some of them have ' rec'
i want to remove that only if those are the last 4 characters
so another words
somestring='this is some string rec'
i want it to be:
somestring='this is some string'
what is the python way to approach this?
...
Hi,
I have a string:
"116,118,120,130"
and will want to delete either the first, last or any value in between upon execution.
To to this I was using:
"116,118,120,130".gsub('118','')
but the problem is the string contains an extra unnessesary comma:
"116,,120,130"
and if I use
"116,118,120,130".gsub(',116','')
it will remo...
Hi,
I want to create macros that will insert a parameter into a function call. For example, I have function Action() declared below. Action takes as it's inputs an enum for the state number and a formatted string with optional args for the string.
I want to define macros so that instead of calling Action( ActionState1, "someText %d"...