w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
cannot convert parameter 1 from 'char [20][20]' to 'char ** '?
Yeah, this is where the idea that an array can be treated like a pointer falls apart. "char[20][20]" denotes an array of 400 characters, laid out in a 20x20 fashion. It is not an array of 20 pointers to arrays of 20 characters each. Thus it would be incorrect to cast a char[20][20] to a char** (and if you did so explicitly, you'd get garbage results). For the same reason (char[20][20] is not an array of pointers), you can't cast to char *[20]. It is an array of arrays, which is what you've declared for print_array2 and print_array3.

Categories : C

Comparing chars in C++ - argument of type "char" is incompatible with parameter of type "const char *
You have category as a single char and cat is an array of chars (i.e. a char *)... you probably didn't mean to compare a string with a single character

Categories : C++

Char to Hex parameter
Keycodes for ASCII letters are equals to their uppercase char value. So you could do the following: char[] chars = phrase.toUpperCase().toCharArray(); for (char letter:chars) { int keyCode = (int)letter; r.keyPress(keyCode); r.keyRelease(keyCode); } With this loop, the string "Hello World" will give "hello world". It won't work for things like exclamation points. Furthermore, if you wan't the robot to send uppercase letters you will have to simulate a press on the shift key or on the caps lock key. Not sure this method is reliable though. You may as well do a lot a if/else (or a switch) to return the correct key code constant from java.awt.event.KeyEvent.

Categories : Java

Delete char from string X many times
(define myfilter (lambda (lst char cnt) (if (null? lst) '() (if (and (eq? (car lst) char) (> cnt 0)) (myfilter (cdr lst) char (- cnt 1)) (cons (car lst) (myfilter (cdr lst) char cnt)))))) (define delnchars (lambda (str char count) (list->string (myfilter (string->list str) char count)))) > (delnchars "3 i's will be removed, the last -> is here" #i 3) "3 's wll be removed, the last -> s here"

Categories : String

C - Delete the i-th Character from a Writable Char Array
The posted code has undefined behaviour, from strcpy(): Copies the byte string pointed to by src to byte string, pointed to by dest. If the strings overlap, the behavior is undefined. Also copies the terminating null-byte. memmove() can used to accomplish the task, remembering to copy the null terminator.

Categories : C

How can I retrieve a char* parameter from a C DLL file, by using VB6
Some parameters of Byte_read are character arrays rather than strings. There is a related answer which explains how to access string parameters. Try as alternative: Private Declare Function Byte_read Lib "RFID_VC_VB1.dll" ( _ ByVal Mode As Long, _ ByVal nCom As Long, _ ByRef head() As byte, _ ByRef status() As byte, _ ByRef adresse() As byte, _ ByRef number() As byte, _ ByRef Data() As byte) As Long You have to map the strings to the byte arrays. Make use of the fact that the last byte is zero.

Categories : String

char pointer as function parameter
Because you print the size of the pointer, and not what it points to. Arrays decays to pointers, and as soon as you pass it to a function you have a pointer instead, and loose all size information of the original array.

Categories : C

C# calling C DLL, pass char * as parameter not correct
When you only receive one character like that, it normally means that you are passing a Unicode (UTF16) string to a C/C++ function that is expecting an 8 bit format such as ASCII, UTF8 or ANSI. The 16-bit Unicode format ends up with one byte of its two bytes being set to zero for characters in the ASCII/ANSI range, and because a C/C++ program treats a zero byte as an end-of-string character, it truncates the string. It's easy to try using ANSI to see if it helps; change CharSet = CharSet.Auto to CharSet = CharSet.Ansi

Categories : C#

Regex extract string without last char parameter
Use a positive lookahead: /^.*?(?=,)/ Example use: preg_match('/^.*?(?=,)/', "Hello world, Another day to die.", $matches); echo "Found: {$matches[0]} "; Output: Found: Hello world

Categories : PHP

Multithreading - const char array passed as parameter
The memory referred to by myStr.str().c_str() is immedately destroyed (because the temporary std::string returned by myStr.str() is destructed), so the thread is dereferencing a dangling pointer (causing undefined behaviour). To correct, ensure the pointer supplied to laodFunc() remains valid for the lifetime of thread. Or, change the const char* pFilePath to std::string const& pFilePath: loadFunc(const map<uint16_t, string> & pClasses, std::string const& pFilePath); boost::thread *new_thread = new boost::thread(&loadFunc, classes, myStr.str()); and a copy of myStr.str() will be stored internally and passed to the thread function (see Thread Constructor with arguments). It is worth nothing that the classes argument will also be copied, even though the parameter t

Categories : C++

^char type hint not permitted for clojure defn parameter
This is based on the comments from @A. Webb and @kotarak, as far as I can understand them. There are two aspects to this: first, why the ^char is available in some contexts (e.g. in for)? This, is necessary not only for optimizations, but for correct Java interop as your example shows. Also, it looks (to me) relatively cheap to implement, as each variable is independent, so it can be processed by itself. This is not the case with function definition, where for each combination of supported type you have to define a new interface: e.g. static public interface L{long invokePrim();} static public interface D{double invokePrim();} static public interface OL{long invokePrim(Object arg0);} // ... static public interface OLD{double invokePrim(Object arg0, long arg1);} // all the way to static

Categories : Clojure

Passing char* as a parameter to dynamically called function gives runtime error
You are assuming that BigStruct looks exactly like an array of 2000 characters. This is compiler dependent and unlikely to be true. I guess you really want to copy the data pointed to by cur into the el array and not to write it all over BigStruct itself which will have some internal storage format that you cannot know.

Categories : C

C incompatible integer to pointer conversion passing 'int' to parameter of type 'const char *';
#include <stdio.h> #include <stdlib.h> #include <string.h> #include <ctype.h> char *toLowerCase(const char *uppercase){ char *temp = malloc(strlen(uppercase)+1); if(temp){ char *p = temp; while(*p++ = tolower(*uppercase++)); /* while(*uppercase){ *p++ = tolower(*uppercase++); } *p = ''; */ } return temp; } int main(void){ char *str = toLowerCase("ABC-XYZ"); printf("%s ", str);//abc-xyz free(str); return 0; }

Categories : C

is char** x = (char**) arg equivalent to reinterpret_cast(const_cast(arg) )?
Yes they are basically the same except the c++ style cast shows the reader of the code that you are doing some weird stuff while its harder to notice with the c style. Its legal yet as always its highly suspect when a const incoming parameter is being cast as non const.

Categories : C++

ODP.NET delete statement can not pass DBNull as parameter value
AND x = NULL doesn't equate to true when x is null. Try using IS NULL or the isnull() function. See Not equal <> != operator in T-SQL on NULL for more info

Categories : Dotnet

Get input parameter value for gridview delete (enable)
The RowDeleting event documentation shows an example that sounds a lot like what you're trying to do. In fact, you need to even do less than that example. You should assign an event handler to your grid's RowDeleting event and then in the event handler method display a simple Hello, World message.

Categories : Vb.Net

Parameter for "Delete" post method has blank attributes in ASP.NET MVC
You don't seem to be passing the "bookToDelete" parameter through to the DELETE method. In fact you shouldn't be passing this through as it's an object not a simple value. I would pass the "book id" through on delete post action (same as delete get action) Altering the delete view form code by adding the following line between the @Using Html.BeginForm() and End Using lines @Html.HiddenFor(model => model.id) And change the DELETE post method in your controller to Function Delete(id as string) As ActionResult Dim originalBook = _db.ISBNs.Find(id)

Categories : Asp Net Mvc

How do I write Sql server delete statement where a column value starts with the value of a parameter
Try this one - CREATE PROCEDURE [dbo].[storedProcedureName] @parameterName VARCHAR(30) AS BEGIN DELETE FROM dbo.[Table1] WHERE Table_ColumnNames LIKE @parameterName + '%' END

Categories : SQL

PHP Header Location with parameter. Delete and back to previous list
Checkout the parse_url and parse_str functions. http://www.php.net/manual/en/function.parse-url.php http://php.net/manual/en/function.parse-str.php

Categories : PHP

Delete method with array type as parameter showing null value
Try changing data: "ArrMenuId"+ JsArrayMenuId, to data: {ArrMenuId : JsArrayMenuId.join()} and changing public HttpResponseMessage DeleteAllMenu(Array ArrMenuId) to public HttpResponseMessage DeleteAllMenu(string ArrMenuId) I don't think javascript array will translate easily into a c# array and by changing it to this you are instead passing a string. Once you have this comma delimited string you can make it into an array in your c#

Categories : Asp Net Mvc

IntelliSense: argument of type "_TCHAR *" is incompatible with parameter of type "const char *"
Your project is configured for Unicode which means that the _TCHAR macro evaluates to wchar_t, which is a 16 bit UTF-16 data type on Windows. But the library you are calling accepts 8 bit char data. So, you will need to make both sides of the interface match. Lots of ways to do that. The obvious options are: Change your project to target ANSI (change the character set to multi byte in the VS project configuration). Convert the input argument from UTF-16 to ANSI before calling the library. It seems to me to be needlessly complex to use _TCHAR these days. That was useful when we needed to support Win9x (no Unicode support) and WinNT (supports Unicode) from a single code base. But I expect that nowadays you are targeting NT based systems and so you are safe to assume support for Unicode

Categories : Visual Studio 2010

Sending 'const char *' to parameter of type 'const uint8_t *' error
In addition to the signed/unsigned pointer warning, your code can actually be wrong. [kHeader length] returns the number of Unicode characters in the string, and this can be different from the number of UTF-8 bytes returned by [kHeader UTF8String]. For example, @"€" has one Unicode character, but 3 UTF-8 bytes. So you should replace that by const char *utf8string = [kHeader UTF8String]; [outputStream write:(const uint8_t *)utf8string maxLength:strlen(utf8string)]; or alternatively NSData *data = [kHeader dataUsingEncoding:NSUTF8StringEncoding]; [outputStream write:[data bytes] maxLength:[data length]];

Categories : IOS

How is a string literal equal to char*, and how should I take a string as a parameter
surely it is a pointer to a single char, not an array of chars It's a pointer to the first character of an array of char. One can access each element of the array using a pointer to its first element by performing pointer arithmetic and "array" indexing. What datatype should the parameter be? const char *, if you don't wish to modify the characters from within the function (this is the general case), and char * if you do.

Categories : C

Delete multiple rows by sql statement "delete from tableName" whereas TRIGGER "After Delete" had applied on that
Either set @roid=(select ReachOutID from deleted(nolock) where deleted.NotificaionType='reachoutlike') Or set CACHE_Reachout.LIKEcount= (select [dbo].[getReachout_Notification_Count](@roid,'like') ) where CACHE_Reachout.ReachOutID=@roid is returning more than 1 row of data. Raj

Categories : Sql Server

Templatized ostream overload ambiguity error : basic_ostream vs const char[]
The non-template operator does not cause any ambiguity because that operator itself is not viable for resolving this call: return out << "a1"; // ^^^^^^^^^^^ // This MUST be `std::operator <<`, no other valid overload of // operator << is found! As well as the other similar ones. The template version, on the other hand, is viable, since T is not bound to be any concrete type: template <class T> ostream& operator<<(ostream& out, const T& a) { switch(a) { case T::a1 : return out << "a1"; // ^^^^^^^^^^^ // Here the compiler could invoke std::operator << // OR it could invoke your operator << template, // which is also viable since T could be anything! //

Categories : C++

Unable to pass an address of array of type char *[2] to function taking char ***
char *array[2] = {"string", "value"}; is an array with 2 elements of char *. Using array as an address results to a pointer to the first element, i. e. of type char **. Using &array results to a pointer to the same place, but of type char *(*)[2] (not sure if the spelling is right). This is not the same as a char *** - the representation in memory is completely different. To be more verbose, +++++++++++++++++++++++ + array[0] + array[1] + +++++++++++++++++++++++ this is the array. char ** p1 = array; // is a pointer to the first element, which in turn is a pointer. char *(*p2)[2] = &array; // is a pointer to the whole array. Same address, but different type, i. e. sizeof(*p1) != sizeof(*p2) and other differences. char ***p3 = &p1; // Now, p1 is a different pointer va

Categories : C

char pointers, char arrays, and strings in the context of a function call
The char[] signature in the parameter is exactly the same as char*. In C++, it is illegal to convert a string constant char const* (the string "Kacy") to a char* because strings are immutable. Your second example compiles because the name is an actual array. There is no change to char*. As a solution, change your parameter to take a const string array: Student(char const name[]); which again is the same as String(char const *name); though you're better off using std::string: #include <string> class String { public: String(std::string name); };

Categories : C++

C - Sort char string in array to equal char user input
OK, so basically you want to convert a sorted array of letters to a specific (random?) ordering and record the swaps along the way, right? Here is one way to do this. #define SWAP(a,b) a^=b;b^=a;a^=b int main(int argc, char* argv[]) { char* wordInput=argv[1]; char* newWord = (char*)malloc((strlen(wordInput) + 1) * (sizeof(char))); int i,j,k; fprintf(stdout, "Word is %s ", wordInput); // Sort wordInput into newWord. for (i=0; i<strlen(wordInput); i++) { // Put this one at the end. newWord[i]=wordInput[i]; // Start at the back of the string, and move it forward if it is less. for (j=i-1; j>=0; j--) { if (newWord[j+1] < newWord[j]) { SWAP(newWord[j+1], newWord[j]); } else { break; } } } newWord[strlen(wordInput)]

Categories : C

How to disable type char in JTextArea but enable removed char (Backspace)
try to put DocumentFilter instead of DocumentListener something like final AbstractDocument abstractDocument = (AbstractDocument) textArea.getDocument(); abstractDocument.setDocumentFilter(new DocumentFilter() { @Override public void remove(final FilterBypass fb, final int offset, final int length) throws BadLocationException { super.remove(fb, offset, length); } @Override public void insertString(final FilterBypass fb, final int offset, final String string, final AttributeSet attr) throws BadLocationException { if (getLineCountAsSeen(textArea) < 4) { super.insertString(fb, offset, string, attr); }

Categories : Java

How can I write a function boolean succeeds(char a, char b, String s)? using s.equals(""), s.charAt(0), s.substring(1)
Something like this should work. I have not compiled this. Hopefully it gets you in the right direction, even with possible syntax errors. public boolean succeeds(char a, char b, String s){ boolean sawFirst= false; for(int i=0;i<s.length();i++){ if(!sawA){ if(s.charAt(i)==b) sawFirst = true; } else{ if(s.charAt(i)!=a) return false; else sawFirst= false; } } return true; }

Categories : Java

Printing the memory representation of an integer using char* and unsigned char*
This is because (on your system) char is signed, and it's getting promoted to int in the printf() call. Use unsigned char: void print_bytes(const unsigned char *ptr, size_t len) { for(size_t i = 0; i < len; ++i) { printf("%p %x ", ptr + i, ptr[i]); } }

Categories : C

Regarding type safety when storing an unsigned char value in char variable
"does this mean that char could maintain its 'signedness' throughout the comparison?" yes; -1 as a signed char will be promoted to a signed int, which will retain its -1 value. As for the unsigned char, it will also keep its 255 value when being promoted, so yes, the comparison will be false. If you want it to evaluate to true, you will need an explicit cast.

Categories : C

What to call method which returns char* ( String in Java and char* in C++)?
It returns a String object and you can use the JNI string functions to convert that string to a char*: char* gPGGetName() { jobject objStr = env->CallObjectMethod(g_Obj, g_s3eGPGGetName); jsize len = env->GetStringUTFLength(objStr); const char* strPtr = env->GetStringUTFChars(objStr, 0); char* buffer = (char*)malloc((len + 1) * sizeof(char)); memcpy(buffer, strPtr, len); buffer[len] = ''; env->ReleaseStringUTFChars(objStr, strPtr); return buffer; }

Categories : Android

Why does GCC accept convertion from 'const char *' to 'char *' on std::strrchr() returned value?
Actually your g++ does not accept the conversion from 'const char *' to 'char *', it's just that on your version std::strrchr() returns a char* (incorrectly, instead of a const char*). To verify the first part of my statement, try to compile the following on your GCC versions, I predict that all will correctly issue an error: int main() { const char* p = "foo"; char* q = p; // error, invalid conversion from 'const char*' to 'char*' } Now for the second part, I tried to compile the following minimal code, whose actual aim is to trigger an error in order to list the declared overloads of std::strrchr: #include <cstring> void (*p)() = &std::strrchr; // error here, with "candidates are: ..." int main() {} Well, with gcc 4.7.2 the message shows the expected "all non-c

Categories : C++

How compare a char / single char string - with some list of alphabets set
If the starting letter is always an English character (or anything representable by a reasonably small integer that fits into an unsigned char), then here's a solution (the fastest possible one I can think of - uses no jumps except for the first check for initialization and only plain old integers are used instead of the somewhat heavier-weight comparison of NSString instances): - (UIColor *)colorFromName:(NSString *)name { static UIColor *strs[1 << CHAR_BIT] = { nil }; static BOOL initted = NO; if (!initted) { strs['a'] = [UIColor greyColor]; strs['b'] = [UIColor whiteColor]; // ... strs['z'] = [UIColor blueColor]; initted = YES; } unsigned char first = tolower([name characterAtIndex:0]); return strs[first]; }

Categories : IOS

Unexpected Error C2632: 'char' followed by 'char' is illegal
Those types have already been created via typedef (maybe) or #define (more likely) before your code tries to do it; taking a look at the preprocessor output (if that's possible with Visual-C++) may help you track down why that is.

Categories : Visual C++

Java regex : matching a char except when preceded by another char
You need a negative lookbehind for that: String.Split("(?<![\\]);"); Here is a demo on ideone.

Categories : Java

How to duplicate string token to char */char array
Call c_str on the string: word[i] = (const char *)strdup(t.c_str()); For reference: http://en.cppreference.com/w/cpp/string/basic_string/c_str

Categories : C++

Unhandled Exception when converting const char to char
Both your contents of buff and buffA are in read-only memory of the process. You will actually need to new your buff like char* buff = new char[32]; This provides memory from the free-store and you can then strcat the string from buffA to buff. You should prefer strncat, though to avoid buffer-overruns and delete your buff eventually.

Categories : C++

why does passing char[] not work, but (deprecated conversion) char* does?
You have a problem in that you store pointers to local variables in the structure. In the case of the test_char2 array, it no longer exists once the get_struct function returns. This means that the pointer a_char2 no longer points to a valid string, and dereferencing this pointer is undefined behavior. The reason the first pointer works, is because it doesn't point to a local variable, it points to a string literal, and those are stored elsewhere in memory. When coding in C++, there is no longer a reason to use pointers or arrays for string, instead use the std::string class.

Categories : C++



© Copyright 2017 w3hello.com Publishing Limited. All rights reserved.