Skip to main content
Ala
Senior
Oct 4, 2020 7:53 AM UTC
Question

functions stop working

had anyone have the experience of <string.h> functions stop working and prevent the whole programm to proceed?

    This topic has been closed for replies.

    3 replies

    KnarfB
    Super User
    Oct 4, 2020 10:07 AM UTC

    No. Would be helpful if you provide more details...

    Ala
    AlaAuthor
    Senior
    Oct 4, 2020 10:27 AM UTC

    thanks KnarfB

    here is the example:

    below you can see two functions, they both are same, but call() works and sms() doesn't:

    void call(void){
     
    ret=strstr(Rcv,"CALL");	//cheking "Call" phrase in Rcv array
    if (ret) 
    {
    Rcv[(int)(ret-&Rcv[0])]='X';	//check mark to avoid looping
    			 
     for(int n=0;n<13;n++) //check which user to call
    {
    Call_Num[n]=Rcv[(int)(ret-&Rcv[0])+5+n];
    }
    for(int j=0;j<MaxUsers;j++) //check which user is selected to be called
     {
    if(strcmp(Call_Num,USERS_Num[j])==0) //check which user is selected to be called
    { 
    //do stuff	
    	}
     }
    }
    }
    void sms(void){
    ret=strstr(Rcv,"SMS");	//cheking "SMS" phrase in Rcv array
    if (ret) 
    {
    Rcv[(int)(ret-&Rcv[0])]='X';	//check mark to avoid looping
    for(int n=0;n<13;n++) //check which user to send sms
    {
    SMS_Num[n]=Rcv[(int)(ret-&Rcv[0])+4+n];
    }
    for(int j=0;j<MaxUsers;j++) //check which user is selected to send an SMS
    { 
    if(strcmp(SMS_Num,USERS_Num[j])==0) //check which user is selected to send an SMS
    {	 
    //do stuff	
    					}
    			 }
    }
    }

    in debugger mode I check and I see that USERS_Num[0] is just equal with Call_Num and SMS_Num. line 13th of sms() doesn't recognize this. also sometimes call() doesn't work eighter!

    why is that?

    TDK
    Oct 4, 2020 3:01 PM UTC

    I think you need to better define the problem you're having. "Doesn't work" is ambiguous. Nobody else knows what your program is trying to do except you, we can only assume. The bug is probably not in the <string.h> file.

    "If you feel a post has answered your question, please click ""Accept as Solution""."