@rahul: There is something more to static than to retain old value. Are u sure it is not used anywhere else for any other purpose, bcoz i dont think thats the whole purpose of this keyword..
On 8/30/12, rahul <[email protected]> wrote: > static doing nothing, just to make a candidate confuse in interview. > static comes into picture, when u calling same function again and again and > u need some variable to retain the old value, and another scenario when u > have to define the scope of variable. > > > On Thu, Aug 30, 2012 at 6:02 PM, Puneet Gautam > <[email protected]>wrote: > >> Well, its gives error in every array assignment.."ISO forbids this type >> of >> assignment". >> @rahul: But whats with the static here. how does it affect any string >> declared..? I couldnt get your answer ..pls explain >> >> On Thu, Aug 30, 2012 at 12:54 PM, rahul <[email protected]> wrote: >> >>> old style C, where you can't have auto array. just that. >>> >>> >>> On Thu, Aug 30, 2012 at 12:52 PM, Romil ....... >>> <[email protected]>wrote: >>> >>>> It should give an error in the line " names[3] = names[4] " >>>> These are fixed address values..you cannot change them. >>>> >>>> >>>> On Thu, Aug 30, 2012 at 12:44 PM, Puneet Gautam >>>> <[email protected] >>>> > wrote: >>>> >>>>> #include<iostream.h> >>>>> int main() >>>>> {static char names[5][20]={"pascal","ada","cobol","fortran","perl"}; >>>>> int i; >>>>> char *t; >>>>> t=names[3]; >>>>> names[3]=names[4]; >>>>> names[4]=t; >>>>> for (i=0;i<=4;i++) >>>>> cout<<names[i]<<endl; >>>>> getchar(); >>>>> return 0; >>>>> } >>>>> >>>>> >>>>> Whats the importance of static keyword here..? >>>>> >>>>> -- >>>>> You received this message because you are subscribed to the Google >>>>> Groups "Algorithm Geeks" group. >>>>> To post to this group, send email to [email protected]. >>>>> To unsubscribe from this group, send email to >>>>> [email protected]. >>>>> For more options, visit this group at >>>>> http://groups.google.com/group/algogeeks?hl=en. >>>>> >>>> >>>> >>>> >>>> -- >>>> Romil >>>> Software Engineer, >>>> Winshuttle Softwares India Pvt. Ltd. >>>> Chandigarh >>>> >>>> >>>> -- >>>> You received this message because you are subscribed to the Google >>>> Groups "Algorithm Geeks" group. >>>> To post to this group, send email to [email protected]. >>>> To unsubscribe from this group, send email to >>>> [email protected]. >>>> For more options, visit this group at >>>> http://groups.google.com/group/algogeeks?hl=en. >>>> >>> >>> -- >>> You received this message because you are subscribed to the Google >>> Groups >>> "Algorithm Geeks" group. >>> To post to this group, send email to [email protected]. >>> To unsubscribe from this group, send email to >>> [email protected]. >>> For more options, visit this group at >>> http://groups.google.com/group/algogeeks?hl=en. >>> >> >> -- >> You received this message because you are subscribed to the Google Groups >> "Algorithm Geeks" group. >> To post to this group, send email to [email protected]. >> To unsubscribe from this group, send email to >> [email protected]. >> For more options, visit this group at >> http://groups.google.com/group/algogeeks?hl=en. >> > > -- > You received this message because you are subscribed to the Google Groups > "Algorithm Geeks" group. > To post to this group, send email to [email protected]. > To unsubscribe from this group, send email to > [email protected]. > For more options, visit this group at > http://groups.google.com/group/algogeeks?hl=en. > > -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
