Topic profile page for sizeof operator in c.
This page has aggregated data from forum posts, threads, listings, online discussions, newsgroups, messageboards, and other online sources which contain user generated content for the term: sizeof operator in c.
Started 10 hours, 48 minutes ago (2008-11-18 19:25:04)
by ArkM
Fortunately you CAN'T invent a "class of no designated size" in C++. For every class its objects have fixed and defined size (remember operator sizeof). If you mean a class with dynamically allocated members then it's a problem of this class constructor, not a vector container. That's why class constructors were invented.
Started 4 days, 4 hours ago (2008-11-15 01:31:27)
by aryan1423
یک کلاس به نام Int تعریف کردم که یک آرایه دارد که هر خانه از این آرایه معادل با یک رقم از عدد بزرگ ورودی است و در کلاس یک operator برای جمع نوشته ام. کد: //YA HAGH #include using namespace std; struct Int { int a[105]; int tool; Int() { memset(a,0,sizeof a); tool=1; } void getnum() { tool=0; while(true) { char inp; scanf("%c",&inp); if (inp==' ' || inp=='')...
Started 4 days, 16 hours ago (2008-11-14 13:43:00)
by itCbitC
Quote: Originally Posted by iampatrickzhang sizeof , (int) and *(deref) are all unary operators in my code, they are in the same order of precedent. (int)(*p) will return an object suitable for sizeof operation. That's because you can't mix a type-name and an object in the same expression
Started 6 days, 2 hours ago (2008-11-13 03:29:00)
by pinniped
Maybe this would help you: http://publib.boulder.ibm.com/infoce...c05cplr199. htm If you choose to use 'malloc' then it's simply: char **blah = malloc(sizeof(char *)*ARRAY_SIZE); If you want to use the new() operator: char **blah = ::new char *[ARRAY_SIZE]; (and to delete: ::delete [] blah; ) As in C, those strange sequences of ()* and so on can get confusing; ...
Started 1 week, 1 day ago (2008-11-10 12:15:19)
by localp
• • • • Originally Posted by ArkM cin >> char_array extracts only one word from input stream (upto whitespace occured - blank, tab or newline). The rest of typed string will been extracted with the next operator >> calls. For example if the user typed "Happy Guppy" then only Happy will be extracted from cin. To discard a tail of unnecessary input, call...
Started 2 weeks ago (2008-11-04 13:28:00)
by matsp
Quote: Originally Posted by master5001 I got bored after seeing the conversation switching back and forth between senior members. I hope someone brought up the placement new operator at some point. Example: Code: myClass *x = new(malloc(sizeof(*x))) myClass; Yes, but that is REALLY not a ...
Started 2 weeks ago (2008-11-04 08:10:00)
by Raman
We are trying to write a C compiler using LEX and YACC Given the production rules, it uses syntax directed translation to generate three address code. TAC.l Code: %{ #include #include %} LETTER [A-Za-z] DIGIT [0-9] OPERATOR [+-*/=&|!(){}] FOR "for" WHILE "while" IF "if" DO "do" ELSE "else" THEN "then" %% {LETTER} {strcpy(yylval.id,yytext); return LETTER;}...
Started 2 weeks, 1 day ago (2008-11-04 04:01:46)
by ramanvis05
We are trying to design a C compiler using LEX, YACC that outputs the C syntax to three address code with LEX and YACC lex TAC.l yacc -d TAC.y gcc -c lex.yy.c -o TAC.lex.o With the following error: Expected specifier-qualifier-list before ETYPE Can someone please help out? TAC.l Help with Code Tags ( Toggle Plain Text ) %{ #include "y.tab...
Started 2 weeks, 1 day ago (2008-11-03 22:00:00)
by kenzo1234
I have inherited some code that I am converting from VS2005 to VS2008. The code has a custom allocator which is passed in as the second arg to a std::vector. The code compiles (and works) in debug, but does not compile in release. The error and the source code sample are below. All resonable and helpful suggestions are welcome. One thing that has occured to me is that there might be a bug in ...
Started 2 weeks, 1 day ago (2008-11-03 17:27:00)
by jbode
quote: Originally posted by Soapbar: oh and I tried doing a quick google of size_t and couldnt get a definintion? Is it a sort of int dedicated to being a counter? The size_t type is an unsigned integral type, returned from the sizeof operator; it's guaranteed to be able to represent the size in bytes of the largest object in memory, regardless of how large that object is. Most ...
Started 1 week ago (2008-11-12 01:35:00)
by P4R4N01D
I am currently working on a (Windows GUI) calculator that accepts impix notation and (hopefully) will contain most of the features of a standard scientific calculator (like sin, cos and tan) w/ the eventual aim being for it to do calculus. However the first objective is to perform standard operations. I was wondering if it would be easier to work completely in impix or convert impix into ...
Started 4 days, 12 hours ago (2008-11-14 17:40:00)
by P4R4N01D
I have changed the function to use char*s instead, but am getting alot of warnings and produces a segmentation fault on runtime. Here is the updated ConvertToPolishNotation: Code: //Pass in inputqueue for reading, and outputqueue for writing char ConvertToPolishNotation(char *inputqueue, char *outputqueue) { char operatorqueue[50]; char *currentpointer = inputqueue; //...
Started 4 days, 17 hours ago (2008-11-14 12:43:00)
by iampatrickzhang
why sizeof (int)(*p) is not compilable by gcc? I thought sizeof, (int) and * has the same order of precedence and the association should be right to left, but sizeof (int)(*p) is wrong. I have to use sizeof ((int)(*p)) instead. Also, sizeof (int) *p is interpreted as (sizeof(int) )* p instead of sizeof ((int)(*p)) as I expected. Any reason? Thanks for any tips
Started 5 days, 18 hours ago (2008-11-13 12:06:00)
by Klotzkopp
Zitat: Zitat von eryx mh mir is das zu hoch ^^ noch nie was von sizeof usw gehört :o was macht der befehl? sizeof ist ein Operator, kein Befehl. Befehle gibt's eigentlich in C und C++ gar nicht. sizeof gibt die Größe (Speicherbedarf) eines Typs (oder des Typs eines Ausdrucks) zurück, und zwar zur Compilezeit (Ausnahme: VLAs in C99). sizeof( char ) ist...
Started 1 week, 1 day ago (2008-11-10 19:46:00)
by dipling
0 ist zero (integer). !0 ist true und !!0 ist false Zitat: Aber wieso besteht bool aus mehreren bits?? Das erfordert der C++-Standard. Es läuft darauf hinaus, dass ein char (sind mindestens 8Bit) im Speichermodell von C++ die kleinste adressierbare Einheit ist (nicht die einzelnen "Bits") sowie die Größe sämtlicher Objekte (Variable)...