Ok I think I got it. So is it right, that in my case I can not know if the char *name that I get is a literal or not so to be sure it's not I have to create a temp array?
error1408
Posts
-
Problem with Array of char* -
Problem with Array of char*DavidCrow wrote:
How about something like: char *temp = new char[strlen(name) + 1]; strcpy(temp, name); Helper::instance()->strtoken(temp, ".", token);
Ok this works! But I don't understand why...could someone explain it to me? Why does the param char * not work but the char * thats created here? Btw. I have to DELETE the char *temp afterwards, right?
-
Problem with Array of char*Ok thx. I will try it in the evening today and post my results.
-
Problem with Array of char*But if I call it with that char* it crashes! I have a function
doSomething(char *name)
{
[...]
strtoken(name, ".", token); //crashes
}That works but it does not help me:
doSomething(char *name)
{
[...]
char foo[] = "hello.world";
strtoken(foo, ".", token); //does NOT crash
}But how can I use strtoken with char *name? Can I make a char foo[] out of char *name?
-
Problem with Array of char*Your right, I get a char* name as a parameter and use it to call the function. Thats the cause of the crash. But how do I solve this problem? I have this char *name and it has to be tokenized. How can I do that as strtok crashes with it? Btw. thanks for your help, I would have never thought of THAT ^^
-
Problem with Array of char*Ok look, here is the full function (that I did NOT write myself) which should work correct, but I think >>I<< do something NOT correct. Its a tokenizer for char-strings
int strtoken(char *str, char *separator, char *token[])
{
int i = 0;token\[0\] = strtok(str, separator); //This line crashes while ( token\[i\] ) { i++; token\[i\] = strtok(NULL, separator); } return ( i ); }
And I call it that way atm:
char \*token\[256\]; //I think that is an array of char\*, isn't it? for(int i = 0; i < 256; i++) { token\[i\] = '\\0'; } Helper::instance()->strtoken(name, ".", token);
name is a char* e.g. "system.fullscreen"
-
Problem with Array of char*Hi, I have a function in a class that has the following sig:
int strtoken(char *str, char *separator, char *token[])
for the *token I do this before:
char *token[256];
for(int i = 0; i < 256; i++)
{
token[i] = '\0';
}I call the function but at this line it crashes:
token[0] = strtok(str, separator);
Error on writing etc. (German Error, so I don't know exactly what it's called in english) Can someone help me?
-
10 is not the new 6 (at least so far.)Oh no I...must...hide....C++ Book.... :laugh:
-
The best possible ref for CSSI never saw it before, but I think it's a really great source of inspiration and I'm sure I can learn a lot from it.
-
What IDE for C++?Ok and why do you think I should use vi, gvim, or BBEdit? What are the special features? Do they provide code completion or sth. like the Intelli-Sense in VS? C# and other languages[^]
-
What IDE for C++?Thank you very much!!
-
What IDE for C++?Hi, I want to learn DX10 and C++, I know C#, Java etc. So I also know VS2008 EXPRESS as IDE for C#. But is it as good for C++ as well? I'd like to know what you think, which IDE is best for developing with C++ and why? Thx
-
Is Regex faster?Ok i wrote a little app that compares the two methods. I found out, that testing a file with 60000 lines 30 times took my pc about a second with this method:
using (StreamReader rIn = new StreamReader("test.txt")) { string line = ""; while ((line = rIn.ReadLine()) != null) { if (line.Trim() == "{{{tcl") { return true; } } rIn.Close(); } return false;
and about 9 seconds with the regex:using (StreamReader rIn = new StreamReader("test.txt")) { string line = ""; Regex reg = new Regex(@"\s*\{\{\{tcl\s*"); while ((line = rIn.ReadLine()) != null) { if (reg.IsMatch(line)) { return true; } } rIn.Close(); } return false;
Thats a BIG difference. -
Is Regex faster?Hi, if you had to search 50000 lines of code for the word example as fast as possible, with every kind of whitespace in the line, which method would you prefer. REGEX or myString.Trim() == "example"
-
Static Method to get Data from DB?Thank you very much!:-D
-
Static Method to get Data from DB?Hi, if i make a static method, that gets Data from my DB, will the method be threadsafe? I mean while one user requests some data and the method is running, can another user that wants to do the same, read/write the variables in this static method? I know it's a beginners question, i searched a lot but i didn't find an answer. Thanks for helping me in advance.
-
How to add xml-Stylesheet line to xml-file? [modified]THANK YOU. You're the man! Why didn't i see it before? At last the ugly code can be banished! Hurray :)
led mike wrote:
You should probably provide that information in your initial post.
Yes perhaps :)
-
Strange Problem at writing fileThank you very much.
Luc Pattyn wrote:
The solution: 1. either use a different file name 2. or remove all background reader candidates (bad idea) 3. or implement the retry loop as Explorer has it (use a Windows.Forms.Timer for this)
1. and 2. are no solutions for me. I have to try 3. I think. I hoped i don't have to use a timer :(
-
How to add xml-Stylesheet line to xml-file? [modified]I searched the documentation for my problem. And i found nothing. I checked every method. And because i found nothing, i asked you.
-
Strange Problem at writing fileI tried it. But it doesn't have an effect. Here is my code at the moment:
//some loop
XmlDocument doc = new XmlDocument();
doc.Load(FullFilePath);
.......//do sth.
doc.Save(FullFilePath); //<-There the error happens
//end of loop