Current time: 02.05.2024, 09:37 Hello There, Guest! (LoginRegister)
Language: english | russian  

Post Reply 
Threaded Mode | Linear Mode
Продукция Microsoft
Author Message
gamecreator Offline

Posts: 7107
Post: #15

Code:
int* foo()
{
    int *res;
    int *var;
    int *tmp;
    res=(int*)calloc(10,sizeof(int));
    var=(int*)calloc(10,sizeof(int));
    for(int i=0;i<10;i++){res[i]=i;var[i]=10-i;}
    tmp=var;
    var=res;
    res=tmp;
    free(var);
    return res;
}
в лучшем случае возвращаемый массив будет забит нулями или мусором. в худшем - runtime error на "free(var);"


When all gods have burnt to ashes in eternity of sorrow,
Demons gonna tear your soul because there is no tomorrow.
28.07.2011 00:34
Find all posts by this user Quote this message in a reply
« Next Oldest | Next Newest »
Post Reply 


Messages In This Thread
Продукция Microsoft - GreyGhost - 23.07.2011, 23:48
RE: Качество продукции Microsoft - gamecreator - 24.07.2011, 01:17
RE: Качество продукции Microsoft - gamecreator - 24.07.2011, 02:36
RE: Качество продукции Microsoft - GrayFace - 24.07.2011, 02:54
RE: Качество продукции Microsoft - gamecreator - 24.07.2011, 03:40
RE: Продукция Microsoft - GrayFace - 28.07.2011, 00:12
RE: Продукция Microsoft - gamecreator - 28.07.2011 00:34
RE: Продукция Microsoft - GrayFace - 31.07.2011, 17:36
RE: Разные вопросы - FallenAngel - 24.07.2011, 00:00
RE: Разные вопросы - GreyGhost - 24.07.2011, 00:05
RE: Разные вопросы - FallenAngel - 24.07.2011, 00:16
RE: Разные вопросы - gamecreator - 24.07.2011, 00:23
RE: Разные вопросы - Flashback - 24.07.2011, 22:11
RE: Разные вопросы - GreyGhost - 24.07.2011, 00:29
RE: Разные вопросы - gamecreator - 24.07.2011, 00:39
RE: Разные вопросы - GreyGhost - 24.07.2011, 01:00

Forum Jump:

Powered by MyBB Copyright © 2002-2024 MyBB Group