type « char « C Data Type Q&A

Home
C Data Type Q&A
1.binary
2.bit
3.byte
4.char
5.character
6.decimal
7.Development
8.float
9.hex
10.integer
11.prime
12.random
13.struct
C Data Type Q&A » char » type 

1. char is signed or unsigned by default    stackoverflow.com

In the book "Complete Reference of C" it is mentioned that char is by default unsigned. But i am trying to verify this with GCC as well as visual studio. It is ...

2. how to convert from char* to char[] in c    stackoverflow.com

here is a code sample

void()
{
   char c[100];
   scanf("%s",c);
   char c2[100]=c;
}
my problem is when i do this assignment an error says that i can assign
char ...

3. Difference between signed / unsigned char    stackoverflow.com

So I know that the difference between a signed and unsigned int is that a bit is used to signify if the number if positive or negative, but how does this ...

4. In C How can I convert an int to a char[] without using snprintf or itoa?    stackoverflow.com

Pulling my hair out here, but I need to convert an int to a string in C without using snprintf or itoa. Any suggestions? I tried using:

/*
**  LTOSTR.C -- routine ...

5. How does direct data access with a NpyIter (new API) work? How do I deal with the char * type?    stackoverflow.com

I'm throwing up my hands here and hoping that someone here will know enough about the new NpyIter API in Numpy's C API to quickly let me know what I'm doing ...

6. Type conversion error: cannot convert from 'char' to '...*'.    bytes.com

Your approach is incorrect for C++. In addtion, your are using RTTI which is very slow and requires that you hard-code type names in your code. This forces a re-code when new types are added. It is generally a design flaw to use RTTI. RTTI is part of C++ in order to provide the ability to make emergency fixes to old ...

7. Typecasting for Class of Template Data type to unsigned char *    bytes.com

If you mean you want a (unsigned) char * to the data contained by the class A which I assume is probably actually a dynamic array of some sort then the answer is you can not use a cast, you need to write a method on the class. You could write a casting operator but on the whole that is bad ...

8. integral (non char) types allow padding?    bytes.com

Hello I am trying to figure out if the standard allows integral type representations with padding (ie value representation != object representation). A conforming implementation can have: - a 32bit int and 32bit unsigned int but have the unsigned int not use the sign bit for value representation? (so INT_MAX == UINT_MAX == 2^32-1) - a 33bit int and a 33bit ...

9. char_traits of user defined "char" type    bytes.com

Good day, c++ guys. I have a question about char_traits of user defined "char" type. I need a string type, which supports "long" as its "char" type, so I defined a lstring like this: typedef basic_string

10. char *, unsigned char * and POD types    bytes.com

Hi, at first the code doesn't seem to work. Any ideas?: #include #include int main() { using namespace std; int x= 7; char *p= reinterpret_cast(&x); for(size_t i= 0; i< sizeof(x); ++i) cout<< p[i]<< '\n'; } Two more questions. Q1) Is the above char * use guaranteed to work with all POD types? Q2) If I remember well, unsigned ...

11. HELP on char data type    bytes.com

My code: char name1, name2; int votes1, votes2; float total votes; cout<<"Enter name of candidate: "; cin>>name1; cout<<"Enter number of votes: "; cin>>votes1; cout<<"Enter name of candidate: "; cin>>name2; cout<<"Enter number of votes: "; cin>>votes2; But if I run the program then input a character, it execute all the code... output: enter name of candidate: mark enter number of votes: enter ...

12. (const char *cp) and (char *p) are consistent type, (const char **cpp) and (char **pp) are not consistent    bytes.com

There is a warning/(error? I remember it is an error for line 10 on some compilers before. At least on g++, it is an error.) for line 10. I first read a similar example from `Expert C Programming -- Deep Secrets, Perter van der Linden'. But I wonder why line 9 is ok but line 10 is illegal? Is what Keith ...

14. A beginner level problem with char datatype    cboard.cprogramming.com

#include #include #include #include int main() { int n1,i; int buff_size = 26; char * y; y = (char *)malloc(sizeof(char)*buff_size); if (y == NULL) { fprintf(stderr, "Malloc returned void pointer\n"); exit(EXIT_FAILURE); } for (i=0; i

15. Represenation of char type    cboard.cprogramming.com

16. type char vs type int    cboard.cprogramming.com

17. program.c:50: warning: subscript has type `char'    cboard.cprogramming.com

> Then how do you approach the fact that int is a signed data type and no warnings are given when you use it as > a subscript? But an int is _always_ signed, so there's less chance of confusion (though I personally always use an unsigned type for an index). It appears that the OP may be assuming that any ...

18. error involving char type    cboard.cprogramming.com

#include #include typedef struct { int x; int y ; }POINT; int main() { POINT ent; char quad; printf("\nEnter a point, x variable then y variable\n"); scanf("%d %d", &ent.x, &ent.y); if ( ent.x >= 0, ent.y >= 0) { quad = "I"; } else if ( ent.x < 0, ent.y >= 0 ) { quad = "II"; } else ...

19. char datatype?    cboard.cprogramming.com

#include int main() { int num1; int num2; char yorn; printf ("enter a basic number: "); scanf ("%d", &num1) ; printf("now enter another number: "); scanf ("%d", &num2) ; printf ("u entered %d and %d\n", num1, num2); printf ("-------\n"); printf ("would you like to multiply? , Y/N\n"); scanf ("%c", &yorn); getchar(); if ( yorn == 'y' || yorn == 'Y' ...

20. the correct syntax for ''char'' type    cboard.cprogramming.com

21. Char Type    cboard.cprogramming.com

22. field `chars' has incomplete type    cboard.cprogramming.com

23. [char][type]    forums.devshed.com

Jim's right. If you want the itext to be an empty string, then you set the first character to '\0' (AKA NUL, as Jim describes). But if you want to set itext to NULL, which is to say the null pointer, then you cannot do that with itext. NULL says that the pointer doesn't point to anything, which can never be ...

24. char var type - C    forums.devshed.com

26. C : Type Conversion, int to char    forums.devshed.com

thanx for your prompt reply, dude! I need to store it in a specific location in the array. I am trying to do a stricmp, if there is a match, put in the corresponding index. The program is supposed to convert Word to Number. eg. user input : forty five program returns : 45 <<

27. char* types and cstrings    forums.devshed.com

pstring and pstring2 are pointers. So you are comparing pointers. I was surprised that your code compiled at all. But, apparently the compiler knows that the string "estimation" is stored somewhere in memory where it cannot be changed, which just happens to be the same place that pstring is pointing to. So, the pointer to "estimation", and pstring both point to ...

28. type mismatch in redeclaration simple_readline (*char)    daniweb.com

/* */ #include #include #include main() { char* inputstr; inputstr = simple_readline( "Please specify the input string (one more notification))" , 0); printf("\n You've specified string = %s\n", inputstr); getchar(); getchar(); } char* simple_readline( const char* prompt, unsigned block_size ) { char* result; /* The malloc()ed string to return */ *result = "efef"; return result; }

29. how to prevent int accepts char typed in? (urgent)    daniweb.com

char input[255] = {0}; // input buffer char *ptr; printf("Enter a number\n"); fgets(input,sizeof(input),stdin); // get keyboard // now strip off the trailing '\n' that fgets() add to the end of the string ptr = strrchr(input,'\n'); if( ptr != NULL) *ptr = '\0'; // now check each character for digits. // If any non-digits are found then loop // back to the ...

31. converting Enum type from int to char    daniweb.com

void convertEnum(Food foodItem[],Category category) { int i = 0; switch (category) { case 0: strcpy(foodItem[i].category, "meat"); break; case 1: strcpy(foodItem[i].category, "poultry"); break; case 2: strcpy(foodItem[i].category, "seafood"); break; case 3: strcpy(foodItem[i].category, "dairy"); break; case 4: strcpy(foodItem[i].category, "vegetable"); break; case 5: strcpy(foodItem[i].category, "fruit"); break; case 6: strcpy(foodItem[i].category, "grain"); break; case 7: strcpy(foodItem[i].category, "sweet"); }

32. userdefine datatype to char* conversion.    codeproject.com

33. Operand Types Are Incompatible ("char *" and "int")    codeproject.com

The RED[i] is coming to me as a char* If I do "1" then the warning goes away but logic isn't executed. If I do '1' then the warning says char* and char incompatible The [i] is coming to me as a my_ulonglong data type from an online mysql database if that helps.

java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.