Note that there are some explanatory texts on larger screens.

plurals
  1. POUnhandled exception - how to solve it, c++
    primarykey
    data
    text
    <p>I am having troubles with this program. Compiler gives me, after successfull program compilation this: Unhandled exception in the "0x0f6bd540 (msvcr100d.dll)" в "progBUS.exe"<br> What is wrong whith the program, because everything seems to work well, but in the end, after pressing "Enter" to exit console, mistake - Unhandled exception is given. How to fix it? Thanks a lot! </p> <pre><code># include &lt;iostream&gt; # include &lt;cstring&gt; using namespace std; template &lt; class T&gt; void switcher(T &amp;a, T &amp;b){ T c=a; a=b; b=c; } char* f(char* word){ static char* ss("u"); static int iter(0); cout&lt;&lt;"word \""&lt;&lt;word&lt;&lt;"\" has been thrown\n"; if ( strcmp(word,ss)!=0 &amp;&amp; strcmp(word,"")!=0) {ss=word; iter=0;} //if another word has been thrown cout&lt;&lt;"ss="&lt;&lt;ss&lt;&lt;" iter="&lt;&lt;iter&lt;&lt;endl; static char ret[15];//return word value memset(ret, '\0', 14);//clean up ret value int len = strlen(ss); int j=0; if (iter == len-1) return nullptr;//we have reached the end of word for (int i=iter;i&lt;len;i++){ //cout&lt;&lt;"*(ss+i)="&lt;&lt;*(ss+i)&lt;&lt;endl; if (*(ss+i)!=' ') ret[j]=*(ss+i); else { iter=i+1; return ret;} //cout&lt;&lt;*(ss+i); j++; if(i==len-1) {iter=i+1; return ret;} } return nullptr; } int main(){ int a=1,b=2; cout&lt;&lt;f("fr rewfer ewr")&lt;&lt;endl; cout&lt;&lt;f("fr rewfer ewr")&lt;&lt;endl; cout&lt;&lt;f("43 34")&lt;&lt;endl; cout&lt;&lt;f("")&lt;&lt;endl; cout&lt;&lt;f("")&lt;&lt;endl; cout&lt;&lt;f("fr rewfer ewr")&lt;&lt;endl; //char ss[]("fr rewfer ewr"); //size_t len = (sizeof ss)/(sizeof ss[0]); // cout&lt;&lt;"len="&lt;&lt;len&lt;&lt;endl; system("PAUSE"); return 0; } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload