[c-prog] Re: const char const string[] = Hello ;

2009-09-06 Thread peternilsson42
--- In c-prog@yahoogroups.com, izecksohn izecks...@... wrote: I know the title does not work, but: Should it compile? It's generally preferred that you put the whole question in the body, rather than referring readers to the title. Re: const char const string[] = Hello ; gcc does not

[c-prog] Re: plz solve

2009-08-12 Thread peternilsson42
Akash Goswami akashgoswam...@... wrote: The answer should be how are you because float double is not same data type. They may still have the same representation, just as int and long may have the same representation. -- Peter

[c-prog] Re: plz solve

2009-08-11 Thread peternilsson42
achyuth .. achyuth_...@... wrote: float a, double b; data typemismatch though it was same precision value.. c-language doenot support u d cohersion i.e.auto converion of datatypes.. so statement works like that only.. Even if English is not your first language, you can still get yourself a

[c-prog] Re: how to Sort boost collection class using multi sorting options/criteria

2009-08-10 Thread peternilsson42
ch.a...@... ch.a...@... wrote: Hi I am using boost collection class. I did sorting e.g apply a quick/bubble sort algo , but i want to do sorting using multiple criteria. how we can implement using boost. Do boost have any classes or functions through which I can easily sort the data

[c-prog] Re: plz solve

2009-08-09 Thread peternilsson42
From: rajanchatter...@... Uday Oberio wrote: float a=1.1; double b=1.1; if(a==b) printf(hello); else printf(how are u ); I am new one in c++. printf is rarely used in C++. so please tell me it's answer. I am eagerly waiting for your reply. What do _you_ think, and

[c-prog] Re: Weird code..!

2009-07-26 Thread peternilsson42
Sanjeev Gopinath sanjeevsinc...@... wrote: Hello there! I came across this weird code. Can anyone help in explaining the logic involved..? There is no logic as far as I'm concerned. Perhaps you should ask the person who wrote it. #includestdio.h double m[]= {7709179948849219.0, 771};

[c-prog] Re: moving average problem

2009-07-22 Thread peternilsson42
Christopher Coale chris95...@... wrote: peternilsson42 wrote: Christopher Coale chris95219@ wrote: Paul Herring wrote: billcu34billcu1@ mailto:billcu1%40suddenlink.net wrote: double Sma(double *ds, int size) { double res = 0; for (int i = 0; i size; i

[c-prog] Re: I am not agree with u.

2009-07-19 Thread peternilsson42
Michael White michael_whi...@... wrote: ...Everything to the right of the assignment operator '=' happens first. There is no guarantee in C or C++ of that being the case. Unlike some other languages, = is just another operator. In C and C++, side effects are only guaranteed between sequence

[c-prog] Re: function pointers

2009-07-19 Thread peternilsson42
[I've combined and restored some context from multiple posts.] Paul Herring pauljherr...@... wrote: Bill Cunningham wrote: I would like to start writing code and calling functions in C code with a pointer to a function. In C, it's impossible to call a function without using a pointer!

[c-prog] Re: Round Upto function.

2009-07-19 Thread peternilsson42
Niranjan Kulkarni guruof...@... wrote: Hi Everyone, I am witting a function in C++ for any given number to round upto the iRoundTo. Here is the function I have written: void RoundUpTo(float Num, int iRoundUpTo) { int iRem = 0; int iNum = ceil(Num); This defeats the purpose of

[c-prog] Re: I am not agree with u.

2009-07-19 Thread peternilsson42
Dan Presley dpres...@... wrote: c = a/++a; I got a compiler warning about the operation on a (the '++a') being undefined when I compiled the source. When I ran the exe, Mom told me about putting a fork in the toaster, but when I tried it... ... My guess is the compiler, when

[c-prog] Re: Introduction

2009-06-30 Thread peternilsson42
--- In c-prog@yahoogroups.com, Jim Smith jmclauri...@... wrote: Make sure you understand how and why you specify the calling convention using extern C so C++ won't mangle C function names. I'm sorry, extern C is a linkage declaration not a calling convention. Quite so. That said, the

[c-prog] Re: Need help...

2009-06-30 Thread peternilsson42
--- In c-prog@yahoogroups.com, Jim Smith jmclauri...@... wrote: Types bool, char, wchar_t, and the signed and unsigned integer types are collectively called integral types. In C++ yes, however the C standard only uses the word 'integral' to refer to the integer component of a floating point

[c-prog] Re: Introduction

2009-06-30 Thread peternilsson42
--- In c-prog@yahoogroups.com, Jim Smith jmclauri...@... wrote: [...quoted stuff...] [...reply...] [...original message...] Jim, clearly you understand the benefits of bottom posting over top posting, but you could still employ better quoting techniques...

[c-prog] Re: Input hiding in C++

2009-06-25 Thread peternilsson42
--- In c-prog@yahoogroups.com, Sanjeev Gopinath sanjeevsinc...@... wrote: Hey there! I use G++ compiler and I'd like to hide the input which is typed... Just like the password inputs! Is there any function or any idea how this can be implemented? Google for 'no echo' and 'password'. There

[c-prog] Re: Why doesn't this work?

2009-06-21 Thread peternilsson42
--- In c-prog@yahoogroups.com, ayyaz ayya...@... wrote: scanf(%[\^n] ,text); should be scanf(%[^\n] ,text); The carrot tells it take everything except a new line. Perhaps you meant carat, or more accurately caret. Perhaps you even meant caron. But it's actually none of those. It's a

[c-prog] Re: Feistel source code c++

2009-06-21 Thread peternilsson42
--- In c-prog@yahoogroups.com, flixers_3010 flixers_3...@... wrote: please teach us to make a simple program of feistel chiper using c++? It's impractical for us to teach you C++. We can answer specific questions, but unstructured emails are about the worst way for you to learn whole subjects.

[c-prog] Re: C++ editor..

2009-06-21 Thread peternilsson42
SVMAYOL twin_f...@... wrote: where can i download C++ editor? i dont see it in the file of this group...thnx..=) You can edit C++ files with any text editor you like. What C++ implementation (compiler) are you currently using? It's hard to find compilers that don't have IDEs. Even most GNU

[c-prog] Re: Help with SWITCH statement

2009-06-18 Thread peternilsson42
--- In c-prog@yahoogroups.com, ayyaz ayya...@... wrote: Steve Searle wrote: ayyaz scrawled: switch (choice = getchar()) { case 'r': case 'R': printf(RED); break; case 'w': case 'W': printf(WHITE);

[c-prog] Re: char type string to int type variable.

2009-06-15 Thread peternilsson42
--- In c-prog@yahoogroups.com, siddhiruhi011 siddhiruhi...@... wrote: ...we can use library functions to convert character string into integer variable but we can write our own function In other words, we can use trusted source that's (generally) been rigorously tested, or we can reinvent the

[c-prog] Re: template class of array.

2009-06-11 Thread peternilsson42
--- In c-prog@yahoogroups.com, WLJiang WLJiang iamwlji...@... wrote: Well, #include stdio.h haven't any effect,it can delete, and this Statement if(alist == NULL) not have anyquestion. Because in head file already define NULL But you does not make clear how to modified. Don't use NULL

[c-prog] Re: Volatile variable in C

2009-06-11 Thread peternilsson42
peternilsson42 peternilsso...@... wrote: Sharma, Hans Raj \(London\) hansraj_sharma@ wrote: I have never seen difference in the sizeof(char *) and sizeof(int *). Is there any such system with a difference? Why do you care? What advantage would you gain from them necessarily being

[c-prog] Re: class code example

2009-06-11 Thread peternilsson42
Paul Herring pauljherr...@... wrote: peternilsson42peternilsso...@... wrote: Thomas Hruska thruska@ wrote: peternilsson42 wrote: I've never understood why people don't declare classes...   struct student   {     student();     ~student() { cout i am destructor endl

[c-prog] Re: template class of array.

2009-06-11 Thread peternilsson42
--- In c-prog@yahoogroups.com, WLJiang WLJiang iamwlji...@... wrote: But you does not make clear how to modified. Don't use NULL in C++. Use plain 0 as a null pointer constant... if (alist == 0) ... Yeah, I just want know this program how to modified. The key not about alist ==

[c-prog] Re: char type string to int type variable.

2009-06-11 Thread peternilsson42
--- In c-prog@yahoogroups.com, Thomas Hruska thru...@... wrote: ... You are going to get a lot of flak for using gets(). ... atoi() [...] is the easiest method Just as gets() is the easiest (but worst) method. ;) or strtol() (much more portable). More portable, no. More robust, yes. --

[c-prog] Re: Volatile variable in C

2009-06-10 Thread peternilsson42
--- In c-prog@yahoogroups.com, John Matthews jm5...@... wrote: Sharma, Hans Raj \(London\) hansraj_sharma@ wrote: Can someone please help me understand how can I write a program which, using volatile variable, access some memory mapped devices? If you have an 8 bit register at address

[c-prog] Re: Volatile variable in C

2009-06-10 Thread peternilsson42
--- In c-prog@yahoogroups.com, Sharma, Hans Raj \(London\) hansraj_sha...@... wrote: Can we get address of [CPU registers]? How? That would depend on the CPU, but I can't recall a system where registers had addresses since days of yore. Observe that the C language standard does not allow you

[c-prog] Re: class code example

2009-06-10 Thread peternilsson42
--- In c-prog@yahoogroups.com, iamwljiang iamwlji...@... wrote: #includeiostream #includestring.h Use cstring, or better still string. #includecstdlib using namespace std; class student { private: It's a class, the default access is already private. char name[50]; int

[c-prog] Re: template class of array.

2009-06-10 Thread peternilsson42
--- In c-prog@yahoogroups.com, iamwljiang iamwlji...@... wrote: This code have link error,but I can't find it. I need someone help me find it and tell me where is error and why... I use Dev-C++ compile it that the error show is Array(int n=50); and ~Array() link error.

[c-prog] Re: Volatile variable in C

2009-06-10 Thread peternilsson42
--- In c-prog@yahoogroups.com, John Matthews jm5...@... wrote: peternilsson42 peternilsson42@ wrote: I haven't seen a system where this will seriously fail, but I prefer... printf(reg = %u\n, 0u + *reg); Haven't seen that before - thanks. I wouldn't rush to copy it. ;) It's been

[c-prog] Re: Volatile variable in C

2009-06-10 Thread peternilsson42
--- In c-prog@yahoogroups.com, Sharma, Hans Raj \(London\) hansraj_sha...@... wrote: I have never seen difference in the sizeof(char *) and sizeof(int *). Is there any such system with a difference? Why do you care? What advantage would you gain from them necessarily being the same? The

[c-prog] Re: class code example

2009-06-10 Thread peternilsson42
Thomas Hruska thru...@... wrote: peternilsson42 wrote: I've never understood why people don't declare classes... struct student { student(); ~student() { cout i am destructor endl; } void setvalue(const char *); void display() const; private

[c-prog] (unknown)

2009-06-09 Thread peternilsson42
--- In c-prog@yahoogroups.com, piyush dixit piyush_4love_4e...@... wrote: i m not asking for right code. If you just want to write bad code, stop wasting our time!  i want to know why the result is 10 0 0. You've already been given enough clues. John kindly expanded the macro for you [albeit

[c-prog] Re: unpredictable OUTPUT????

2009-06-08 Thread peternilsson42
Sandip Tujare sandip_tuj...@... wrote: From: piyush_4love_4ever piyush_4love_4e...@...   using TerboC/C++     # define swap(a,b)temp=a;a=b;b=temp;   void main()   {   int i=5,j=10,temp=0;   if(ij) swap(i,j);   printf(%d %d %d,i,j,temp);    }     output is 10 0 0.  

[c-prog] Re: reference data type [+moderator comment]

2009-06-03 Thread peternilsson42
--- In c-prog@yahoogroups.com, mina salehi mina_sa2...@... wrote: why reference data type is defined in C++? what does this reference data type do? http://lmgtfy.com/?q=why+reference+data+type+is+defined+in+C%2B%2B%3F Second hit (after the repeated question on Yahoo Answers)

[c-prog] Re: 2 queues one for +ve numbers and other for -ve numbers

2009-06-02 Thread peternilsson42
--- In c-prog@yahoogroups.com, meeda91 meed...@... wrote: The program ask the user to enter 5 numbers +ve and negative ... and the program will put the positive numbers in a queue named pos and negative numbers in queue named neg the program works but when it reach the funciton push it stop

[c-prog] Re: File IO

2009-06-01 Thread peternilsson42
--- In c-prog@yahoogroups.com, glogic20 glo...@... wrote: ... Im writing code that takes data from a text file that updates the positions of my 3d models on a frame per frame basis(.bvh). I am currently writing code that reads in new line each frame (each new line contains new frame data) but

[c-prog] Re: query on const over loading!

2009-05-31 Thread peternilsson42
--- In c-prog@yahoogroups.com, Saurabh Jain hundredr...@... wrote: Gopi Krishna Komanduri gopikomanduri@ wrote: HI,   One more query . I know that we can over loas const member functions by removing const. ... void main() //I am surprised no one nit-picked on void to int conversion.

Re: Fw: [c-prog] confusing outpu Ultimate answer

2009-05-31 Thread peternilsson42
--- In c-prog@yahoogroups.com, mahesh gaikwad maheshg...@... wrote: e.g v=(m++)+(++m) ; if m = 1; first ++m go in stack, then m++ go in stack that's why answer is 4. Please read... http://tech.groups.yahoo.com/group/c-prog/message/70641 -- Peter

[c-prog] Re: [c++-prog] How it inherit Enums in c++.

2009-05-31 Thread peternilsson42
--- In c-prog@yahoogroups.com, girish gandhi girish_gandhi...@... wrote: I want ot extend or inhertis enums. You can't in standard C++, but you can probably do what you want in several ways. Tell us why you want to do this, with sample code and intended usage. But no idea how i can be . Off

[c-prog] Re: query on Inheritence

2009-05-28 Thread peternilsson42
--- In c-prog@yahoogroups.com, Gopi Krishna Komanduri gopikomand...@... wrote: HI,    I have a small query. In virtual inheritence , the function wil be called basing on the object we assign for the base class pointer. But how variable address will be resolved. I observed that even variable

[c-prog] Re: Confusing Output:Final Clear Logical Answer

2009-05-28 Thread peternilsson42
--- In c-prog@yahoogroups.com, Arvind Balodia arvind.balo...@... wrote: As i saw the simple problem of increment and decrement has become an issue of debate in this group and now we are started to blame on each others knowledge. There really isn't anything being debated. There is only

[c-prog] Re: query on const over loading!

2009-05-28 Thread peternilsson42
--- In c-prog@yahoogroups.com, Gopi Krishna Komanduri gopikomand...@... wrote: ... I know that we can over loas const member functions by removing const. consider that I overloaded a const member function. Now consider that I declared a  normal object (non-const). Now how can I access the

[c-prog] Re: to use C#?

2009-05-27 Thread peternilsson42
Note: C-Prog isn't about C#, it's about C and C++. Robert Ryan bobzcp...@... wrote: in compiling C++: it is g++  int1.cpp  For GNU C++ on *nix systems. Under DJGPP it's gpp int1.cpp. and to run C++, it is ./a.out a.out the default, particularly on *nix systems, if you don't specify the

Re: Fw: [c-prog] confusing outpu Ultimate answer

2009-05-27 Thread peternilsson42
Arvind Balodia arvind.balo...@... wrote: Well if you are taking argument of left and right to say that my reasons are wrong. Your reasons are irrelevant. well again Mr. look at the statement again v=(m++)+(++m); Look at the C++ Standard, 5p4 (from my old draft) Except where noted,

[c-prog] Re: error

2009-05-25 Thread peternilsson42
abcpqr70 wrote: i have this line in my code:- err-pu.error_exit =error_exit; when i try to compile it,i get this error:- error: a value of type void (*)(j_common_ptr) cannot be assigned to an entity of type void (*)(j_common_ptr) C what probably is this??- void

[c-prog] Re: limiting precision on float

2009-05-25 Thread peternilsson42
[I'm too lazy to fix the top post today, context elided.] --- In c-prog@yahoogroups.com, Jos Timanta Tarigan jos_t_tari...@... wrote: anyway, is there a way to make my program only works on eg. 3 decimal precision? so in result, everytime I do a floating point precision, it always truncated

[c-prog] Re: limiting precision on float

2009-05-24 Thread peternilsson42
--- In c-prog@yahoogroups.com, Jos Timanta Tarigan jos_t_tari...@... wrote: hi, im currently having a problem try to calculate this: directionZ = -cos((angleX+90)*PI_RADIAN); What is PI_RADIAN? [I'll assume (PI/180).] You could try... directionZ = -cos((angleX+90)/180.*PI); Or more

[c-prog] Re: STL and forward declarations

2009-05-22 Thread peternilsson42
--- In c-prog@yahoogroups.com, xcianox2...@... wrote: Hi all, I tried to use STL for a C++ class that can contain arrays of itself as, for example, a directory tree. Not sure what the little Â's are. I would say your email client is inserting them (and other characters.) It is easy to

[c-prog] Re: Where are my C header files?

2009-05-20 Thread peternilsson42
ngoni2002 ngoni2...@... wrote: peternilsson42 peternilsson42@ wrote: Paul Herring pauljherring@ wrote: [...@pjhxps ~]# find / | grep stdio.h 2/dev/null find / -name stdio.h 2/dev/null The following should work: $locate stdio.h As was previously discussed, 'locate' is not always

[c-prog] Re: Where are my C header files?

2009-05-19 Thread peternilsson42
Paul Herring pauljherr...@... wrote: [...@pjhxps ~]# find / | grep stdio.h 2/dev/null find / -name stdio.h 2/dev/null -- Peter

[c-prog] Re: a problem with eclipse

2009-05-18 Thread peternilsson42
ruhatadiyaman ruhatadiya...@... wrote: i tried all ways. #include stdio.h #includestdio.h Both of these are correct, though the first one is preferred. #includestdio. h #includestdio .h Both of these are wrong. all of them are still underlined. and there is a question mark left of each

[c-prog] Re: help with a program

2009-05-18 Thread peternilsson42
Corey McKee camckee...@... wrote: Try this: snip int DrinkP = 0; int FoodP = 0; int TDp = 0; You know, a large coffee costs $3.70 here. :-) snip system (pause); Yuk. Don't encourage people to do this. Unless you like your software to output messages like... ksh: pause: not found

[c-prog] Re: friend function member of a class

2009-05-14 Thread peternilsson42
mark anthonymor...@... wrote: please help me, with this. im getting 2 errors 1. error C2653: 'Anthony' : is not a class or namespace name 2. error C2248: 'Mark::id' : cannot access private member declared in class 'Mark' i using visual c++ 2008 here is my code.

[c-prog] Re: Difference b/w pointer to pointer and 2D arrays

2009-05-14 Thread peternilsson42
Michael Comperchio mcmp...@... wrote: Peter Nilsson wrote: Michael Comperchio mcmprch@ wrote: ... The declaration... int a[2][3]; ...is... |- [0] --|-- [1] -| +++++++ | [0][0] | [0][1] |

[c-prog] Re: Difference b/w pointer to pointer and 2D arrays

2009-05-12 Thread peternilsson42
Michael Comperchio mcmp...@... wrote: /* A reference to an object of type array-of-T which appears in an expression decays (with three exceptions) into a pointer to its first element; the type of the resultant pointer is pointer-to-T. That is, whenever an array appears in an

[c-prog] Re: how can write a function that returns a string with this setup

2009-05-07 Thread peternilsson42
Muhammad Farooq point4...@... wrote: yah it is true... _What_ is true?! Please start providing some context to your messages. See... http://en.wikipedia.org/wiki/Posting_style -- Peter

[c-prog] Re: malloc

2009-05-06 Thread peternilsson42
Tyler Littlefield ty...@... wrote: p.s. Post script to what? I'm not your bro. If 'bro' causes offence, don't ever go to New Zealand! If 'mate' causes offence, don't ever come to Australia. ;) Thanks, Tyler Littlefield Web: tysdomain.com email: ty...@... My programs don't have bugs,

[c-prog] Re: how can write a function that returns a string with this setup

2009-05-06 Thread peternilsson42
mark anthonymor...@... wrote: Mark.h #pragma once //i am using visual c++ 2008 compiler/ide, this is equvilaent to #ifndef mark_h... etc... Not exactly equivalent, but I won't dwell on that. #include string //is this part needed here? Do you use strings? If so, you'll need the

[c-prog] Re: function that returns a string with this setup

2009-05-06 Thread peternilsson42
Muhammad Farooq point4...@... wrote: hi bro it does not compile What doesn't compile? It's both practical and courteous to quote the text that you're referring to. because int have 4 bytes and you are passing 16 bytes in int so please check must perform casting  for this. You're

[c-prog] Re: how can write a function that returns a string with this setup

2009-05-06 Thread peternilsson42
mark anthonymor...@... wrote: Thanks guys! i have made my sample code work now. I thought i cannot use '#include' and 'std::...' inside a .h file. So what are the differences of .h and .cpp? Do you have any reference texts or tutorials? I sincerely hope you're not trying to learn C++ by pure

[c-prog] Re: .h and .cpp files

2009-05-06 Thread peternilsson42
mark anthonymor...@... wrote: what should be placed inside these files? i had written some code and saved it it in .h and written no more extra .cpp class except for main cpp file(counter to what a book said write definitions to a .cpp file) am i breaking any rules here? Inline function

[c-prog] Re: #define expansion runtime or compile time ?

2009-04-08 Thread peternilsson42
Kiran Divakaran kiran_divaka...@... wrote: Brett McCoy wrote: kiran_divaka...@... wrote: I have a query with #defines in C. There is a -E compiler option which would expand the #define at compile time and create an intermediate file and create the object file for the same.

[c-prog] Re: C language

2009-04-07 Thread peternilsson42
From: roshni anju roshni_a...@... Is there anyone who can plz tell me What does Main() function return by default in 'C' Language. A hosted implementation is required to support at least two forms of main: int main(void) int main(int, char **) Portable return values are 0, EXIT_SUCCESS

[c-prog] Re: New group member

2009-04-05 Thread peternilsson42
Thomas Hruska thru...@... wrote: Dave wrote: Hello to the group. ... Good morning, Dave - :) (Obligatory '2001: A Space Odyssey' reference...or 'Independence Day', whichever) I don't think HAL says that in the Kubrick movie or in the original Arthur C Clarke book. He does say Good

[c-prog] Re: pointer basic

2009-03-31 Thread peternilsson42
kathir resh resh_personal@ wrote: Did you #include stdio.h? You must supply a prototype for variadic functions like printf. If you don't, you have no real right to expect anything, let alone explain it. main() Better to avoid implicit int... int main(void) { char *p=hai friends,*p1;

[c-prog] Re: stdint.h and UINT8_MAX

2009-03-17 Thread peternilsson42
Steve Searle st...@... wrote: I'm trying to use stdint.h after seeing it mentioned here the other day. Using g++ under fedora. GNU's support of C99 is incomplete... http://gcc.gnu.org/c99status.html For the most part though, it is fairly straight forward to create and substitute your

[c-prog] Re: an example about factorial numbers

2009-03-16 Thread peternilsson42
ruhatadiyaman wrote: thanks for all replies. i tried them but still the problem is continuing. this is my code with 'unsigned long int'; /*factorial*/ snip so after 13 the results are wrong :( otherwise i confused with usage of long double. % type fact.c #include stdio.h

Fw: Re: [c-prog] binary to decimal without using arrey or pointer or function

2009-03-12 Thread peternilsson42
John Matthews jm5...@... wrote: John Matthews jm5678@ wrote: peternilsson42 peternilsson42@ wrote: However main() is optimised effectively to a no-op since the compiler was able to recognise that foo(i) will indeed equal bar(i) for the iterated values of i! I'm not disputing

Fw: Re: [c-prog] binary to decimal without using arrey or pointer or function

2009-03-11 Thread peternilsson42
John Matthews jm5...@... wrote: praveen indian85 praveen_indian85@ wrote:    dec=dec+temp*pow(2,i); pow() takes double arguments and returns a double. The following would be more appropriate: dec += temp * (1 i); BTW is (int)pow(2, i) guaranteed to return the same as (1

[c-prog] Re: Non-0 internal value for NULL (C)

2009-03-04 Thread peternilsson42
John Matthews jm5...@... wrote: Say: int fn1(void) { int *p = NULL; return !p; } int fn2(void) { static int *p; return !p; } On a machine where NULL is represented internally by 0, NULL is a macro. It doesn't have a representation per se. You should be talking

[c-prog] Re: compilling error massage

2009-02-25 Thread peternilsson42
real shrinil...@... wrote: Thomas Hruska thruska@ wrote: real wrote: i am not able to understand the massage. What I Know Is... Massage is the practice of soft tissue manipulation with physical, functional, and in some cases psychological purposes and goals. pl guide what is the error

[c-prog] Re: C99: func() and func(void)

2009-02-23 Thread peternilsson42
John Matthews jm5...@... wrote: In C99, if you have the following function prototypes: void funcX(); This is _not_ a prototype in C99 (or C90.) void funcY(void); funcX declares a function with no parameter specification, No, it declares a function with an unspecified number of

[c-prog] Re: C99: func() and func(void)

2009-02-23 Thread peternilsson42
John Matthews jm5...@... wrote: Paul Herring pauljherring@ wrote: John Matthews jm5678@ wrote: peternilsson42 peternilsson42@ wrote: John Matthews jm5678@ wrote: In C99, if you have the following function prototypes: void funcX(); This is _not_ a prototype in C99

[c-prog] Re: Integer constant suffix

2009-02-15 Thread peternilsson42
John Matthews jm5...@... wrote: An example from the code I'm working on is a 'maximum number of users' constant. Whereas the number of milliseconds in a second is (you would hope) a 'constant' constant. Reminds me of... The primary purpose of the DATA statement is to give names to

[c-prog] Re: Integer constant suffix

2009-02-15 Thread peternilsson42
John Matthews jm5...@... wrote: Jim Dougherty j_dougherty@ wrote: c-prog@yahoogroups.com wrote: jimdougherty j_dougherty@ wrote: I still don't get it. Can you give me an example where it would be wrong to use 1000 rather than 1000L ? It would be useful to do this in an

[c-prog] Re: converting binary to decimal numbers in c programming...

2009-02-01 Thread peternilsson42
Christopher Coale chris95...@... wrote: ...this converts a binary string(1001011101) to a decimal value(605). long Bin2Dec(const char *bin) { long p = 0; long r = 0; long len = strlen(bin) - 1; for (long i = len; i = 0; i--,p++) { if (bin[i] == '1')

[c-prog] Re: Memory allocation

2008-12-02 Thread peternilsson42
Titi Anggono [EMAIL PROTECTED] wrote: I allocated memory to one array, which stores data from one file, Are you trying to read a whole file? If so, why? and I made a condition that if one data being read using fscanf() is larger than the threshold value the program close. I just read

Res: [c-prog] Re: integer promotions

2008-11-28 Thread peternilsson42
Pedro Izecksohn [EMAIL PROTECTED] wrote: --- peternilsson42 wrote: -Wconversion Warn for implicit conversions that may alter a value. ... Integral promotions don't alter the value. Maybe you need -Wsign-conversion gcc -Wall -Wsign-conversion problem.c -o problem cc1: error

[c-prog] Re: making a makefile to compile multiple programs

2008-11-28 Thread peternilsson42
Tyler Littlefield [EMAIL PROTECTED] wrote: Hello, My makefile skills are horrible as it is, but, I'm looking for some pointers. Look to the internet. Whilst there are common elements, makefile formats can and do differ between different implementations. ...I'm not even really sure where to

[c-prog] Re: appliction crashing

2008-11-28 Thread peternilsson42
Gopi Krishna Komanduri [EMAIL PROTECTED] wrote: Hi,  While I am trying to debug the following code ,... snip --- On Fri, 28/11/08, Pedro Izecksohn [EMAIL PROTECTED] wrote: From: Pedro Izecksohn [EMAIL PROTECTED] Subject: Re: Res: [c-prog] Re: integer promotions Please don't start a new

[c-prog] Re: query on Exception handling (in constructor and desctructor)

2008-11-27 Thread peternilsson42
Gopi Krishna Komanduri [EMAIL PROTECTED] wrote: Hi, I have a query related to exceptional handling. I pasted the code I tried following this mail. My intention is , what happens in a sistuation when any exception is caught in main , so while destructing the objects till that instant

[c-prog] Re: query on prefix and post fix operator overloading

2008-11-27 Thread peternilsson42
Gopi Krishna Komanduri [EMAIL PROTECTED] wrote:    I have a small query. why we need to return reference in prefix operator overloading. http://www.parashift.com/c++-faq-lite/operator-overloading.html#faq- 13.14 http://www.parashift.com/c++-faq-lite/newbie.html#faq-29.3 -- Peter

Res: [c-prog] Re: integer promotions

2008-11-25 Thread peternilsson42
Pedro Izecksohn [EMAIL PROTECTED] wrote: peternilsson42 wrote: [ unsigned short int a; a = USHRT_MAX; /* previously a = -1; */] So you made absolutely _no_ change to the semantics of that assignment! I fixed the signal to make others happy. You must be referring to Thomas

Res: Res: [c-prog] Re: integer promotions

2008-11-25 Thread peternilsson42
Pedro Izecksohn [EMAIL PROTECTED] wrote: --- peternilsson42 wrote: Ah, then you've probably been fooled by the cliché that C is just portable assembler. If I could do just one modification to the standard, I'd add an overflow macro, like errno. The behaviour on integer overflow

[c-prog] Re: unary operators

2008-11-25 Thread peternilsson42
Brett McCoy [EMAIL PROTECTED] wrote: str = i == 1 ? is : are; It's known as the tertiary or ternary operator, BTW. It should be known by its name: conditional operator. -- Peter

[c-prog] Re: Help required for creating enum

2008-11-25 Thread peternilsson42
u will know when u IM me [EMAIL PROTECTED] wrote: I want to create an enum variable whose size is 4 byte in 32- machine and 8 bytes on 64 bit machines. Your nearest bet is... enum my_enum { my_enum_constant = INT_MAX; } my_enum_variable; Basically, I want to knopw whether one can specify

Res: [c-prog] Re: integer promotions

2008-11-25 Thread peternilsson42
Pedro Izecksohn [EMAIL PROTECTED] wrote: --- Thomas Hruska wrote: peternilsson42 wrote: Pedro Izecksohn [EMAIL PROTECTED] wrote: peternilsson42 wrote: [ unsigned short int a; a = USHRT_MAX; /* previously a = -1; */ ] So you made absolutely _no_ change to the semantics

[c-prog] Re: integer promotions

2008-11-23 Thread peternilsson42
Tyler Littlefield [EMAIL PROTECTED] wrote: hello, If you multiply two unsigned shorts together, you'll get an unsigned short, No, you won't. If the range of unsigned short fits into an int, the two unsigned short values will be promoted to int. The multiplication will be performed with ints,

[c-prog] Re: integer promotions

2008-11-23 Thread peternilsson42
Pedro Izecksohn [EMAIL PROTECTED] wrote: If The integer promotions preserve value including sign. There are several 'promotion' rules at play in C (and C++.) For integers with a 'rank' less than int, if the range of the integer type fits into the range of int, then that type will promote to

[c-prog] Re: integer promotions

2008-11-23 Thread peternilsson42
Pedro Izecksohn [EMAIL PROTECTED] wrote: For peternilsson42: I was not clear and you did not read message 68798. http://tech.groups.yahoo.com/group/c-prog/message/68798 That post contained detail missing from your original post. However, it did not contain detail which explained why you

[c-prog] Re: Command line parameters

2008-11-09 Thread peternilsson42
jagomaniak [EMAIL PROTECTED] wrote: My program is run in the command line with two parameters: program -param1 param2 Since I'm a beginner, I'm not sure how to do the following: I need the program to check if the param2 includes any characters other than capital letters (A-Z) and

[c-prog] Re: obveious

2008-11-05 Thread peternilsson42
mukeshjadon34 [EMAIL PROTECTED] wrote: shivani gupta fab_shivani@ wrote: From: Brett McCoy idragosani@ Manoj Vivek [EMAIL PROTECTED] wrote: main() { printf(%d, main); } main() { printf(%d, a); } The first snippet does not show any errors while

[c-prog] Re: how to find size without using sizeof??

2008-11-02 Thread peternilsson42
una_020 [EMAIL PROTECTED] wrote: David Hamill david@ wrote: Use sizeof. That's what it's there for! Bearing in mind that structs often incorporate padding, it's not easy to find their size. I suppose you could initialise an area of memory to 0x00, write a struct over it, and see

[c-prog] Re: Something about variables

2008-11-02 Thread peternilsson42
una_020 [EMAIL PROTECTED] wrote: ...it's better you start off by studying complete reference c by herbert schidlt... Schildt is known for his clarity of explanation. Unfortunately, he is also known for having a very poor technical knowledge of C. Indeed, you would probably learn more finding

[c-prog] Re: question about compiler warning

2008-10-26 Thread peternilsson42
frank zhu [EMAIL PROTECTED] wrote: Hi, I've coded a program to find the nth node from the end of the linked list. It works and get me the right result, but I am puzzled as why I get the compiler warnings at the following line, p1 = p1-next; findnthnode.c:28: warning: assignment from

[c-prog] Re: multiple if statements

2008-10-26 Thread peternilsson42
michael.steven86 [EMAIL PROTECTED] wrote: Hi everyone, I'm experiencing a problem with a multiple if statement. I have tried to use braces, but I must be doing something wrong. It's good to see a newbie admit their own mistakes rather an ask if it's a compiler bug! :-) So, I have removed

[c-prog] Re: RE-HELP IN SECRET MESSEGE PROGRAM!

2008-10-19 Thread peternilsson42
hamoodmeero [EMAIL PROTECTED] wrote: WELL ALL I WROTE IN THE TEST QUESTION IS THIS, SO PLEASE CAN U CORRECT ME AND TELL ME WHERE IS THE MISTAKE ?THNXX : For someone dealing in secrets, you sure make a lot of noise! If you can avoid holding the shift or caps locks when coding, please do

[c-prog] Re: const variable: stored in data segment?

2008-10-01 Thread peternilsson42
Arindam Biswas [EMAIL PROTECTED] wrote: Hi Friends, One simple doubt: const int a = 10; // global my_function() { const int b = 20; // local } Will both 'a' and 'b' be stored in data segment? Why do you care? What's more important is whether const means 'constant' or 'don't

[c-prog] Re: const variable: stored in data segment?

2008-10-01 Thread peternilsson42
David Hamill [EMAIL PROTECTED] wrote: Arindam Biswas wrote: const int a = 10; // global my_function() { const int b = 20; // local } Will both 'a' and 'b' be stored in data segment? I suppose it depends on the compiler. KR say that the const keyword may even be ignored by a

  1   2   >