I'm trying to parse a simple text file in an integer method and then output an integer from such file so that other parts of the program can use it. For testing purposes it also displays the character value (9 in this case). The integer value for some reason is 57. I've also tried it with another part of the text file (which in that case...
Hi all,
I'm trying to make a little client-server script like many others that I've done in the past.
But in this one I have a problem. It is better if I post the code and the output it give me.
Code:
#include <mysql.h> //not important now
#include <stdlib.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#includ...
What's the equivelent of char.IsLetterOrDigit() in php 5?
...
Could someone please explain the difference in how the 2 snippets of code are handled below? They definitely compile to different assembly code, but I'm trying to understand how the code might act differently. I understand that string literals are thrown into read only memory and are effectively static, but how does that differ from the ...
How can I search a dynamic array of char in Delphi 6 for a sub-string and get back an index to a match, not a pointer? I've seen functions in Delphi 6 that do this for strings but not for dynamic char arrays. There is a function called SearchBuf but that function returns a PChar pointer to the match location when what I need is the arr...
Hi,
I'm a beginning user in C++ and I want to know how to do this:
How can I 'create' a byte from a string/int. So for example I've:
string some_byte = "202";
When I would save that byte to a file, I want that the file is 1 byte instead of 3 bytes.
How is that possible?
Thanks in advance,
Tim
...
Hi,
When I read one char* from std::cin and I want to write it to std::cout, it prints until it finds a \0 in memory. So what did was:
char c;
cin >> c;
char* pChar = &c;
pChar++;
*pChar = '\0';
println(&c); // My own method: void println(char * str) { cout << str << endl; }
But I don't think this is a safe action.
Is there a safer ...
1- How does this work:
char *ptr = "hi";
Now the compiler will put this string in the memory (I'm guessing the stack), and create a pointer to it? Is this is how it works?
2- Also if it is created locally in a function, when the function returns will the memory occupied by the string be freed?
3- Last but not least, why is this not ...
Okay the previous question was answered clearly, but i found out another problem.
What if i do:
char *test(int ran){
char *ret = new char[ran];
// process...
return ret;
}
And then run it:
for(int i = 0; i < 100000000; i++){
string str = test(rand()%10000000+10000000);
// process...
// no need to delete...
Hi,
I have the following code:
static unsigned char S0_gif[] = {
0x47, 0x49, 0x46, 0x38, 0x39, 0x61, 0x0f, 0x00, 0x0f, 0x00, 0x91, 0x02,
..
};
It's a hex representation of a gif file. I have 500 gifs that I need to store like that so I want to use a vector to make it easier for access.
Something like:
vector<char[]> gifs;
gif.pus...
I am reaing from a file, and when i read, it takes it line by line, and prints it
what i want exactly is i want an array of char holding all the chars in the file and print it once,
this is the code i have
if(strcmp(str[0],"@")==0)
{
FILE *filecomand;
//char fname[40];
char line[100];
...
Hi, i'm trying to make a program that will scan each column of a guitar tab and play a note when it detects a number. I will do this by creating a char array and have the program scan each collumn of an int value. is this possible? if so, how do i do it?
...
i have an array of type char
char *arg[100]
this array its reading the data from somewhere, when that when i print arg[0], it prints the value "help", and when i print the arg[1], it prints the value "exit".. as an example
what i want exactly is to change the arg[0] from "help" to anything else, like "man"
how i can do that???
than...
How can I cast a NSString* into a char?
EDIT:
Thanks to Vladimir for getting me there!
NSString *myString = @"HelloWorld";
const char *stringAsChar = [myString cStringUsingEncoding:[NSString defaultCStringEncoding]];
Hope this helps someone in the future!
...
I have a char* name which is a string representation of the short I want, such as "15" and need to output this as unsigned short unitId to a binary file. This cast must also be cross-platform compatible.
Is this the correct cast: unitId = unsigned short(temp);
Please note that I am at an beginner level in understanding binary.
...
I'm having trouble determining the best way to read some input in for a java program. It needs to read in the individual characters of a roman numeral, and then perform some operation on it.
There are, however, several catches. The input must be read from the standard input, because input redirection is being used.
Additionally, I need...
From a standards standpoint, should I use the following from the C++ <limits> header?
UCHAR_MAX which is the c implementation or
std::numeric_limits<unsigned char>::max() which is the C++ implementation.
The result is equivalent between the two versions but should I choose an implementation based on some standard or on readability and ...
char c1 = 'A';
char c2 = 'F';
char final = (char) c1^c2;
This always return the result i am looking for, but it doesn't work if either c1 or c2 contain special characters.
Any idea what i can change to allow special characters?
Thanks
...
Coincise question: Need to be able to modify contents of char* in c++.
I have a function which is somewhat like this: char* buffer = (char*)FUNCTION
Now I need to modify 'buffer' e.g. do something like this buffer[1] = "h";
Amongst what I have tried is the following:
char *string = "Hello World";
char buffer[65]; //I still ne...
I have a GtkEntry where the user has to enter an IP number or a hostname. When the button is pressed what the user typed into the entry is added to a char. How can I programmatically check if this char contains spaces, the newline character or the tab character? I don't need to remove them, just to know if they exist. Thanks in advance!
...