char

Returning char* in function

I have function: char *zap(char *ar) { char pie[100] = "INSERT INTO test (nazwa, liczba) VALUES ('nowy wpis', '"; char dru[] = "' )"; strcat(pie, ar); strcat(pie, dru); return pie; } and in main there is: printf("%s", zap( argv[1] ) ); When compiling I get the warning: test.c: In function ‘zap’: test.c:17: wa...

Replace CHAR with VARCHAR2

How can I replace CHAR with VARCHAR2 in all tables in a schema? Note: I'm content with a query that returns the ALTER TABLE statements so I can save the script and run it again. ...

How do I apply the for-each loop to every character in a String in Java?

So I want to iterate for each character in a string. So I thought: for (char c : "xyz") but I get a compiler error: StackCharTester.java:20: foreach not applicable to expression type How can I do this? ...

Are L'A' and 'A' totally same?

When we write a program which supports both unicode and multibytes, we often use _T("some string") macro for strings. But, does a character also need to wrap this macro? Are L'A' and 'A' totally same? Don't we need to wrap _T('A') for a character? ...

Pointer problem in C for char*

Hi guys, i use pointer for holding name and research lab property. But when i print the existing Vertex ,when i print the vertex, i cant see so -called attributes properly. For example though real value of name is "lancelot" , i see it as wrong such as "asdasdasdasd" struct vertex { int value; c...

Passing char * into fopen with C.

Hey there, I'm writing a program that passes data from a file into an array, but I'm having trouble with fopen (). It seems to work fine when I hardcode the file path into the parameters (eg fopen ("data/1.dat", "r");) but when I pass it as a pointer, it returns NULL. Note that line 142 will print "data/1.dat" if entered from command l...

how to get rid off garbage in array of chars?

hi, I'm writing a C program but I keep having problems with my array of chars. I keep getting garbage when I print it using prinf. here is an example of what I get when I print it: char at t.symbol is Aôÿ¿ char at tabl[0].symbol is A char at tabl[1].symbol is a char at tabl[2].symbol is a char at tabl[3].symbol is d char at tabl[4]...

Char and Chr in Delphi

The difference between Chr and Char when used in converting types is that one is a function and the other is cast So: Char(66) = Chr(66) I don't think there is any performance difference (at least I've never noticed any, one probably calls the other).... I'm fairly sure someone will correct me on this! EDIT Thanks to Ulrich for the t...

C++ read registry string value in char*

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...

Compare a specific array element to a char with "if" in C?

Rather Trivial Question. So I tried to do this: if(array[0]=="some_string") but obviously it doesn't work... What do I have to do? ...

C++ new line not translating

First off, I'm a complete beginner at C++. I'm coding something using an API, and would like to pass text containing new lines to it, and have it print out the new lines at the other end. If I hardcode whatever I want it to print out, like so printInApp("Hello\nWorld"); it does come out as separate lines in the other end, but if I r...

In C, how do I check if a String contains 2 digits, 1 letter and 4 digits?

In the method I've tried this: int 1, 2, 4, 5, 6, 7; char 3; char display[10]; scanf("%d%d%c%d%d%d%d", &1, &2, &3, &4, &5, &6, &7); display = {1, 2, 3, 4, 5, 6, 7}; But I get errors everywhere and it doesn't work. ...

storing of strings in char arrays in C

#include<stdio.h> int main() { char a[5]="hello"; puts(a); //prints hello } Why does the code compile correctly? We need six places to store "hello", correct? ...

How to test whether a char is NOT in a string? (java, junit)

As title says, im having trouble with my junit tests passing for checking if a character is not in a string and how to check if an empty string doesnt have a character. here is the method i have: public static boolean isThere(String s, char value){ for(int x = 0; x <= s.length(); x++){ if(s.charAt(x) == value){ return true...

Convert sequence of System.Windows.Forms.Keys to a Char

Is there a way to convert a sequence of keystrokes represented by the Keys enum (i.e. System.Windows.Forms.Keys) in a Char. For example: Keys.Oem4 and then Keys.A yields the char á. It must exist somewhere in the WinAPI, because Windows does that for me, when I press keys inside a text-box... I just don't know where. Please help! thanks....

C++ object in memory

Hello. Is there a standard in storing a C++ objects in memory? I wish to set a char* pointer to a certain address in memory, so that I can read certain objects' variables directly from the memory byte by byte. When I am using Dev C++, the variables are stored one by one right in the memory address of an object in the order that they were...

Char C question about encoding signed/unsigned.

Hi guys. I read that C not define if a char is signed or unsigned, and in GCC page this says that it can be signed on x86 and unsigned in PowerPPC and ARM. Okey, I'm writing a program with GLIB that define char as gchar (not more than it, only a way for standardization). My question is, what about UTF-8? It use more than an block of m...

String replace in j2me/javeme double space

How can I replace this "a  b" by "a b" in j2me? the replace() method doesn't accept Strings, but only chars. And since a double space contains two chars, I think i have a small problem. ...

return char1 + char2? Isn't it possible?

I'm trying to return a string from a function. Which basically adds some chars together and return the string representation. string toString() { char c1, c2, c3; // some code here return c1 + c2; // Error: invalid conversion from `char' to `const char*' } it is possible to return boolean values like return c1 == 'x'. Isn't i...

Counting the number of characters in a file

I'm writing a program that for one part asks for the program to print how many characters (including whitespaces) are in a file. The code I have right now though returns 0 every time though and I'm not sure why it isn't counting the characters. public int getcharCount(Scanner textFile) { int count = 0; while(textFile.h...