<?xml version="1.0" encoding="iso-8859-1" ?>
<rss version="0.92">
<channel>
	<docs>http://backend.userland.com/rss092</docs>
	<title>C++ - Risorse gratuite</title>
	<link>http://cpiupiu.altervista.org/forum/</link>
	<description>xx</description>
	<managingEditor>cpiupiu@altervista.org</managingEditor>
	<webMaster>cpiupiu@altervista.org</webMaster>
	<lastBuildDate>Sat, 07 Nov 2009 09:23:59 GMT</lastBuildDate>
<item>
	<title>Amici</title>
	<link>http://cpiupiu.altervista.org/forum/viewtopic.php?p=13123#13123</link>
	<description>Autore: &lt;a href=&quot;http://cpiupiu.altervista.org/forum/profile.php?mode=viewprofile&amp;u=1716&quot; target=&quot;_blank&quot;&gt;Ntony&lt;/a&gt; |&lt;br /&gt;
Risposte: 0 |&lt;br /&gt;Messaggio:
&lt;span class="postbody"&gt;Ciao ragazzi
&lt;br /&gt;
devo realizzare un programma c++ che riceve un file con coppie di nomi tipo:
&lt;br /&gt;

&lt;br /&gt;
AAAAAA   BBBBBB
&lt;br /&gt;
AAAAAA  CCCCCCC
&lt;br /&gt;
BBBBBB  FFFFFFFFF
&lt;br /&gt;

&lt;br /&gt;
Dove A è amico di B e viceversa e lo stesso per le altre coppie.
&lt;br /&gt;

&lt;br /&gt;
Sempre nel file ho un intero X.
&lt;br /&gt;

&lt;br /&gt;
Il mio programma deve restituire i gruppi formati da X persone che hanno più amici in comune.
&lt;br /&gt;

&lt;br /&gt;
Qualcuno ha qualche suggerimento?
&lt;/span&gt;&lt;br /&gt;
</description>
</item>
<item>
	<title>Estrazione componenti rgb</title>
	<link>http://cpiupiu.altervista.org/forum/viewtopic.php?p=13120#13120</link>
	<description>Autore: &lt;a href=&quot;http://cpiupiu.altervista.org/forum/profile.php?mode=viewprofile&amp;u=1890&quot; target=&quot;_blank&quot;&gt;Armaneddon&lt;/a&gt; |&lt;br /&gt;
Risposte: 0 |&lt;br /&gt;Messaggio:
&lt;span class="postbody"&gt;&lt;/span&gt;&lt;table cellspacing=&quot;1&quot; cellpadding=&quot;1&quot; border=&quot;0&quot; align=&quot;center&quot;&gt;  &lt;tr&gt;     &lt;td height=&quot;20&quot;&gt;&lt;span class=&quot;genmed&quot;&gt;&lt;b&gt;Codice:&lt;/b&gt;&lt;/span&gt;&lt;/td&gt;    &lt;td align=&quot;right&quot; class=&quot;genmed&quot;&gt;&lt;a name=&quot;cq&quot; href=&quot;#&quot; onClick=&quot;top.codeResizer(this);return false;&quot;&gt;Espandi/Riduci&lt;/a&gt;&lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;    &lt;td colspan=&quot;2&quot; class=&quot;code&quot;&gt;      &lt;div style=&quot;width:546px; height:66px; overflow:auto; white-space:nowrap;&quot;&gt;	  #include&amp;lt;stdio.h&amp;gt;
&lt;br /&gt;
#include&amp;lt;malloc.h&amp;gt;
&lt;br /&gt;

&lt;br /&gt;
int rows=512,cols=512;
&lt;br /&gt;
unsigned char **img1,**imgR,**imgG,**imgB;
&lt;br /&gt;

&lt;br /&gt;
unsigned char** allocabuffer&amp;#40;int r, int c&amp;#41;;
&lt;br /&gt;
void eliminabuffer&amp;#40;unsigned char **buffer,int r&amp;#41;;
&lt;br /&gt;
void readraw&amp;#40;char *filepath,unsigned char **buffer&amp;#41;;
&lt;br /&gt;
void readrawR&amp;#40;char *filepath,unsigned char **buffer&amp;#41;;
&lt;br /&gt;
void readrawG&amp;#40;char *filepath,unsigned char **buffer&amp;#41;;
&lt;br /&gt;
void readrawB&amp;#40;char *filepath,unsigned char **buffer&amp;#41;;
&lt;br /&gt;
void saveraw&amp;#40;char *filepath,unsigned char **buffer&amp;#41;;
&lt;br /&gt;

&lt;br /&gt;
FILE *out;
&lt;br /&gt;

&lt;br /&gt;
main&amp;#40;&amp;#41; 
&lt;br /&gt;
&amp;#123;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp;int i;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp; imgR=allocabuffer&amp;#40;rows, cols&amp;#41;;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp; readrawR&amp;#40;&amp;quot;C&amp;#58;\\Documents and Settings\\Paolo L\\Desktop\\EIV\\img.raw&amp;quot;,imgR&amp;#41;;
&lt;br /&gt;

&lt;br /&gt;
&amp;nbsp; &amp;nbsp; saveraw&amp;#40;&amp;quot;C&amp;#58;\\Documents and Settings\\Paolo L\\Desktop\\EIV\\img_R.raw&amp;quot;,imgR&amp;#41;;
&lt;br /&gt;

&lt;br /&gt;

&lt;br /&gt;

&lt;br /&gt;
&amp;nbsp; &amp;nbsp; eliminabuffer&amp;#40;imgR,rows&amp;#41;;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp;&amp;#125;
&lt;br /&gt;

&lt;br /&gt;
unsigned char** allocabuffer&amp;#40;int r, int c&amp;#41;
&lt;br /&gt;
&amp;#123;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp;int i;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp;unsigned char **buffer=&amp;#40;unsigned char**&amp;#41;malloc&amp;#40;r*sizeof&amp;#40;unsigned char*&amp;#41;&amp;#41;;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp;for&amp;#40;i=0;i&amp;lt;r;i++&amp;#41;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;buffer&amp;#91;i&amp;#93;=&amp;#40;unsigned char*&amp;#41;calloc&amp;#40;3*c,sizeof&amp;#40;unsigned char&amp;#41;&amp;#41;;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp;return &amp;#40;buffer&amp;#41;;
&lt;br /&gt;
&amp;#125;
&lt;br /&gt;

&lt;br /&gt;
// readraw RGB
&lt;br /&gt;
void readrawR&amp;#40;char *filepath,unsigned char **buffer&amp;#41;
&lt;br /&gt;
&amp;#123;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp;int i;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp;out=fopen&amp;#40;filepath,&amp;quot;rb&amp;quot;&amp;#41;;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp;for&amp;#40;i=0;i&amp;lt;rows*cols*3;i=i+3&amp;#41; fread&amp;#40;buffer&amp;#91;i&amp;#93;,1,1,out&amp;#41;;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp;fclose&amp;#40;out&amp;#41;;
&lt;br /&gt;
&amp;#125;
&lt;br /&gt;

&lt;br /&gt;
void readrawG&amp;#40;char *filepath,unsigned char **buffer&amp;#41;
&lt;br /&gt;
&amp;#123;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp;int i;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp;FILE *source=fopen&amp;#40;filepath,&amp;quot;rb&amp;quot;&amp;#41;;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp;for&amp;#40;i=1;i&amp;lt;rows;i=i+3&amp;#41; fread&amp;#40;buffer&amp;#91;i&amp;#93;,1,cols,source&amp;#41;;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp;fclose&amp;#40;source&amp;#41;;
&lt;br /&gt;
&amp;#125;
&lt;br /&gt;

&lt;br /&gt;
void readrawB&amp;#40;char *filepath,unsigned char **buffer&amp;#41;
&lt;br /&gt;
&amp;#123;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp;int i;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp;FILE *source=fopen&amp;#40;filepath,&amp;quot;rb&amp;quot;&amp;#41;;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp;for&amp;#40;i=2;i&amp;lt;rows;i=i+3&amp;#41; fread&amp;#40;buffer&amp;#91;i&amp;#93;,1,cols,source&amp;#41;;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp;fclose&amp;#40;source&amp;#41;;
&lt;br /&gt;
&amp;#125;
&lt;br /&gt;

&lt;br /&gt;
void eliminabuffer&amp;#40;unsigned char **buffer,int r&amp;#41;
&lt;br /&gt;
&amp;#123;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp;int i;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp;for&amp;#40;i=0;i&amp;lt;r;i++&amp;#41; free&amp;#40;buffer&amp;#91;i&amp;#93;&amp;#41;;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp;free&amp;#40;buffer&amp;#41;;
&lt;br /&gt;
&amp;#125;
&lt;br /&gt;

&lt;br /&gt;
void saveraw&amp;#40;char *filepath,unsigned char **buffer&amp;#41;
&lt;br /&gt;
&amp;#123;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp;int i;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp;FILE *source=fopen&amp;#40;filepath,&amp;quot;wb&amp;quot;&amp;#41;;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp;for&amp;#40;i=0;i&amp;lt;rows;i++&amp;#41; fwrite&amp;#40;buffer&amp;#91;i&amp;#93;,1,1,source&amp;#41;;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp;fclose&amp;#40;source&amp;#41;;
&lt;br /&gt;
&amp;#125;
&lt;br /&gt;
      &lt;/div&gt;     &lt;/td&gt;  &lt;/tr&gt;&lt;/table&gt;&lt;span class=&quot;postbody&quot;&gt;
&lt;br /&gt;

&lt;br /&gt;
Salve, avrei bisogno di un aiuto, dovrei creare un codice c che mi permetta di estrarre da un immagine raw che ho sul computer (sequenza di pixel rgb rgb rgb...) le componenti r, g e b e di salvarle in 3 buffer diversi per poi estrarre la componente y... ho provato a implementare questo codice ma c'è qualcosa che non torna perchè non mi restituisce un immagine a livelli di grigio per le sole componenti r... cosa sto sbagliando?[/code]
&lt;/span&gt;&lt;br /&gt;
</description>
</item>
<item>
	<title>funzioni</title>
	<link>http://cpiupiu.altervista.org/forum/viewtopic.php?p=13114#13114</link>
	<description>Autore: &lt;a href=&quot;http://cpiupiu.altervista.org/forum/profile.php?mode=viewprofile&amp;u=1090&quot; target=&quot;_blank&quot;&gt;francesca80&lt;/a&gt; |&lt;br /&gt;
Risposte: 2 |&lt;br /&gt;Messaggio:
&lt;span class="postbody"&gt;Ciao, ho bisogo di un consiglio. Devo fare un programma che prende in ingresso una funzione matematica (input da tastiera). é  presente qualche strumento che mi aiuti in questa operazione oppure devo farlo manualmente gestendo le proprietà degli operatori, delle parentesi,etc..?
&lt;br /&gt;
grazie per la risposta
&lt;/span&gt;&lt;br /&gt;
</description>
</item>
<item>
	<title>Help per programma C++</title>
	<link>http://cpiupiu.altervista.org/forum/viewtopic.php?p=13112#13112</link>
	<description>Autore: &lt;a href=&quot;http://cpiupiu.altervista.org/forum/profile.php?mode=viewprofile&amp;u=1888&quot; target=&quot;_blank&quot;&gt;maris.p&lt;/a&gt; |&lt;br /&gt;
Risposte: 2 |&lt;br /&gt;Messaggio:
&lt;span class="postbody"&gt;Scrivere un programma C++ che acquisisce da tastiera un numero intero
&lt;br /&gt;
positivo n&amp;lt;=50 e successivamente n numeri interi positivi che suddivide in
&lt;br /&gt;
quattro insiemi A, B, C e D dove A è l'insieme dei numeri dispari, B è l'insieme
&lt;br /&gt;
dei multipli di 4, C è l'insieme dei multipli di 10 e D è l'insieme di tutti gli
&lt;br /&gt;
altri interi. Per finire, il programma deve scrivere separatamente sul video i
&lt;br /&gt;
quattro insiemi, dichiarando quale di essi sia, eventualmente, l'insieme vuoto.
&lt;/span&gt;&lt;br /&gt;
</description>
</item>
<item>
	<title>Aiuto programma c++</title>
	<link>http://cpiupiu.altervista.org/forum/viewtopic.php?p=13111#13111</link>
	<description>Autore: &lt;a href=&quot;http://cpiupiu.altervista.org/forum/profile.php?mode=viewprofile&amp;u=1888&quot; target=&quot;_blank&quot;&gt;maris.p&lt;/a&gt; |&lt;br /&gt;
Risposte: 0 |&lt;br /&gt;Messaggio:
&lt;span class="postbody"&gt;Scrivere un programma C++ che acquisisce da tastiera un numero intero
&lt;br /&gt;
positivo n&amp;lt;=50 e successivamente le componenti reali
&lt;br /&gt;
u1,u2,...,un
&lt;br /&gt;
di un vettore u e ne determina un k-riordinamento ciclico delle componenti
&lt;br /&gt;
(k intero), cioµe il vettore v ottenuto da u traslando tutte le componenti di |k|
&lt;br /&gt;
posti verso destra o sinistra a seconda del segno di k (gli elementi che escono
&lt;br /&gt;
da un lato rientrano dall'altro); infine il programma deve scrivere il vettore v
&lt;br /&gt;
sul video.
&lt;/span&gt;&lt;br /&gt;
</description>
</item>
<item>
	<title>mi aiutate a svolgere un esercizio grazie :</title>
	<link>http://cpiupiu.altervista.org/forum/viewtopic.php?p=13108#13108</link>
	<description>Autore: &lt;a href=&quot;http://cpiupiu.altervista.org/forum/profile.php?mode=viewprofile&amp;u=1884&quot; target=&quot;_blank&quot;&gt;aaaa&lt;/a&gt; |&lt;br /&gt;
Risposte: 1 |&lt;br /&gt;Messaggio:
&lt;span class="postbody"&gt;realizzare un programma che stampi a video tutti i numeri primi da 1 a 100
&lt;br /&gt;

&lt;br /&gt;
&lt;span style=&quot;color: red&quot;&gt;
&lt;br /&gt;
Sezione sbagliata: sposto
&lt;br /&gt;
numerone&lt;/span&gt;
&lt;/span&gt;&lt;br /&gt;
</description>
</item>
<item>
	<title>Errore di accesso alla memoria!!</title>
	<link>http://cpiupiu.altervista.org/forum/viewtopic.php?p=13107#13107</link>
	<description>Autore: &lt;a href=&quot;http://cpiupiu.altervista.org/forum/profile.php?mode=viewprofile&amp;u=1887&quot; target=&quot;_blank&quot;&gt;la_fo&lt;/a&gt; |&lt;br /&gt;
Risposte: 0 |&lt;br /&gt;Messaggio:
&lt;span class="postbody"&gt;Ciao a tutti, sono nuovissimo in questo forum e spero vivamente nel vostro aiuto. 
&lt;br /&gt;
Sto eseguendo un lavoro di connessione tramite TCP/IP di un apparecchio che comunica con il protocollo MODBUS. Ho tutta la libreria delle funzioni del protocollo, ma ho un problema, quando richiamo una determinata funzione si blocca il programma e mi dice &quot;Unhandled exception in MyApp.exe 0xC0000005:Access Violation.&quot; Premetto che quando compilo il codice non mi restituisce alcun errore. Il codice è il seguente:
&lt;br /&gt;
#include &quot;iostream.h&quot;
&lt;br /&gt;
#include &quot;stdafx.h&quot;
&lt;br /&gt;
#include &quot;Remotemodbus.h&quot;
&lt;br /&gt;
#include &quot;TcpServer.h&quot;
&lt;br /&gt;

&lt;br /&gt;
#include &quot;mbu.h&quot;
&lt;br /&gt;
#include &amp;lt;atlimpl.cpp&amp;gt;
&lt;br /&gt;

&lt;br /&gt;
CModbus* pMod=NULL;
&lt;br /&gt;
CShortArray aValues;
&lt;br /&gt;
CByteArray abCoilValues;
&lt;br /&gt;
CRemoteModbus Connessione;
&lt;br /&gt;
CTcpServer Tcp;
&lt;br /&gt;

&lt;br /&gt;
BYTE byDevice;
&lt;br /&gt;
WORD wQuant;
&lt;br /&gt;
WORD wAddr;
&lt;br /&gt;

&lt;br /&gt;
CString Host;
&lt;br /&gt;
WORD Port;
&lt;br /&gt;
WORD TimeOut;
&lt;br /&gt;
WORD nError;
&lt;br /&gt;

&lt;br /&gt;
	void main(){
&lt;br /&gt;

&lt;br /&gt;
	Host=&quot;192.168.255.1&quot;;
&lt;br /&gt;
	Port=502;
&lt;br /&gt;
	TimeOut=5000;
&lt;br /&gt;
     
&lt;br /&gt;
                byDevice=1;
&lt;br /&gt;

&lt;br /&gt;
	wQuant=10;
&lt;br /&gt;

&lt;br /&gt;
	wAddr=0;
&lt;br /&gt;

&lt;br /&gt;
	abCoilValues.SetSize(wQuant);
&lt;br /&gt;

&lt;br /&gt;

&lt;br /&gt;
	if (Connessione.openConnection(Host,Port,TimeOut)){
&lt;br /&gt;

&lt;br /&gt;
		cout&amp;lt;&amp;lt;&quot;\nLa Connessione è stata attivata...\n\n&quot;&amp;lt;&amp;lt;&quot;Si stanno eseguendo le operazione di acquisizione...\n\n&quot;;
&lt;br /&gt;

&lt;br /&gt;
		nError=pMod-&amp;gt;ReadInputStatus(byDevice,wAddr,wQuant,abCoilValues);
&lt;br /&gt;

&lt;br /&gt;
		if (CModbus::ERR_OK!=nError) {
&lt;br /&gt;

&lt;br /&gt;
			AfxMessageBox(pMod-&amp;gt;ErrorMessage(nError)); //show error message
&lt;br /&gt;

&lt;br /&gt;
	}
&lt;br /&gt;

&lt;br /&gt;
  }
&lt;br /&gt;
	else{
&lt;br /&gt;

&lt;br /&gt;
		cout&amp;lt;&amp;lt;&quot;\nErrore:\n&quot;&amp;lt;&amp;lt;&quot;Connessione non stabilita!\n\n&quot;;
&lt;br /&gt;

&lt;br /&gt;
	}
&lt;br /&gt;
	Connessione.CloseConnection();
&lt;br /&gt;
	
&lt;br /&gt;
}
&lt;br /&gt;

&lt;br /&gt;
Quello che accade è che richiama la funzione ReadInputStatus e mi da errore nel seguente punto(riporto il codice della funzione ReadInputStatus):
&lt;br /&gt;

&lt;br /&gt;
WORD CModbus::ReadInputStatus(WORD nAddr, //Modbus device Address 
&lt;br /&gt;
							   WORD nDataStart , //
&lt;br /&gt;
							   WORD nQtd , 
&lt;br /&gt;
							   CByteArray&amp;amp; abCoilValues) {
&lt;br /&gt;
	 
&lt;br /&gt;
	 static WORD const  QUERY_LENGHT=6;
&lt;br /&gt;
	 
&lt;br /&gt;
	 CByteArray abyQuery;
&lt;br /&gt;
	 WORD nReplyLength=(3 + (nQtd + 7) / 8);
&lt;br /&gt;
	 CByteArray  abyReply;//[]  = new int[nReplyLength];
&lt;br /&gt;
	 WORD nError;
&lt;br /&gt;
	 WORD nRespByte;
&lt;br /&gt;
	 WORD nCoil;
&lt;br /&gt;
	 WORD nBit;
&lt;br /&gt;
	 int  iRetry=0;
&lt;br /&gt;

&lt;br /&gt;
	 //set array sizes 
&lt;br /&gt;
	 abyQuery.SetSize(QUERY_LENGHT);
&lt;br /&gt;
     abyReply.SetSize(nReplyLength); 
&lt;br /&gt;
	 //modbus message 
&lt;br /&gt;
	 abyQuery[0]=(BYTE)nAddr; //ADDR	
&lt;br /&gt;
	 abyQuery[1]=READ_INPUT_STATUS; //Function 
&lt;br /&gt;
	 abyQuery[2]=HIBYTE(nDataStart);
&lt;br /&gt;
	 abyQuery[3]=LOBYTE(nDataStart);
&lt;br /&gt;
	 abyQuery[4]=HIBYTE(nQtd);
&lt;br /&gt;
	 abyQuery[5]=LOBYTE(nQtd);
&lt;br /&gt;

&lt;br /&gt;
	 printf(&quot;Stampa Query Message\n&quot;);
&lt;br /&gt;
	 getchar();
&lt;br /&gt;

&lt;br /&gt;
	//Vito		
&lt;br /&gt;
	
&lt;br /&gt;
	ofstream domanda(&quot;Query_Modbus.dat&quot;,ios::app);
&lt;br /&gt;
	domanda&amp;lt;&amp;lt;abyQuery[0]&amp;lt;&amp;lt;abyQuery[1]&amp;lt;&amp;lt;abyQuery[2]&amp;lt;&amp;lt;abyQuery[3]&amp;lt;&amp;lt;abyQuery[4]&amp;lt;&amp;lt;abyQuery[5];
&lt;br /&gt;
	domanda.close();
&lt;br /&gt;
	
&lt;br /&gt;
	//Vito
&lt;br /&gt;

&lt;br /&gt;
	printf(&quot;Prosegui\n&quot;);
&lt;br /&gt;
	getchar();
&lt;br /&gt;
	
&lt;br /&gt;
	 do {
&lt;br /&gt;
		 
&lt;br /&gt;
		 nError=TxRxMessage(abyQuery,(QUERY_LENGHT),abyReply,nReplyLength);
&lt;br /&gt;
		 
&lt;br /&gt;
		 
&lt;br /&gt;
		 if (nError==ERR_OK) {
&lt;br /&gt;
			 if ((abyReply[0]!=abyQuery[0])||(abyReply[1]!=abyQuery[1])) {
&lt;br /&gt;
				 nError=ERR_INV_RESP;
&lt;br /&gt;
			 }
&lt;br /&gt;
			 else {
&lt;br /&gt;
				 nBit=0;
&lt;br /&gt;
				 nRespByte=3;		
&lt;br /&gt;
				 for(nCoil=0;nCoil&amp;lt;nQtd;nCoil++){
&lt;br /&gt;
					 
&lt;br /&gt;
					 if (nBit&amp;gt;7){
&lt;br /&gt;
						 nBit=0;
&lt;br /&gt;
						 nRespByte++;
&lt;br /&gt;
					 }
&lt;br /&gt;
					 
&lt;br /&gt;
					 if ((abyReply[nRespByte] &amp;amp; (0x01&amp;lt;&amp;lt;nBit))&amp;gt;0){
&lt;br /&gt;
						 abCoilValues[nCoil]= TRUE;  
&lt;br /&gt;

&lt;br /&gt;
					 }
&lt;br /&gt;
					 else {
&lt;br /&gt;
						 abCoilValues[nCoil]= FALSE; 
&lt;br /&gt;
					 }
&lt;br /&gt;
					 
&lt;br /&gt;
	//Vito
&lt;br /&gt;
	
&lt;br /&gt;
	ofstream fileprova(&quot;Stato_ingressi.dat&quot;,ios::app);
&lt;br /&gt;
	fileprova&amp;lt;&amp;lt;abCoilValues[nCoil];
&lt;br /&gt;
	fileprova.close();
&lt;br /&gt;
	
&lt;br /&gt;
	//Vito
&lt;br /&gt;

&lt;br /&gt;

&lt;br /&gt;
					 nBit++; //next bit 
&lt;br /&gt;
					 
&lt;br /&gt;
				 }// end for 
&lt;br /&gt;
				 
&lt;br /&gt;
			 }// else 
&lt;br /&gt;
			 
&lt;br /&gt;

&lt;br /&gt;

&lt;br /&gt;
			 
&lt;br /&gt;
		 }//nerror=ERR_OK
&lt;br /&gt;
		
&lt;br /&gt;
		 iRetry++;
&lt;br /&gt;

&lt;br /&gt;
		 ErrorDelay(nError);
&lt;br /&gt;
		 
&lt;br /&gt;
	 } while ((iRetry&amp;lt;m_wRetries)&amp;amp;&amp;amp;(ERR_OK!=nError)); 
&lt;br /&gt;

&lt;br /&gt;
	 
&lt;br /&gt;
	 ThrowModbusException(nError);
&lt;br /&gt;

&lt;br /&gt;
	 return(nError);
&lt;br /&gt;
	 
&lt;br /&gt;
 }
&lt;br /&gt;

&lt;br /&gt;
Si blocca il tutto quando richiama la riga nError=TxRxMessage(...) e non entra proprio in tale funzione.
&lt;br /&gt;
Qualcuno sa cosa potrebbe essere? Ringrazio tantissimo chi mi risponderà.
&lt;/span&gt;&lt;br /&gt;
</description>
</item>
<item>
	<title>funzione seekg</title>
	<link>http://cpiupiu.altervista.org/forum/viewtopic.php?p=13098#13098</link>
	<description>Autore: &lt;a href=&quot;http://cpiupiu.altervista.org/forum/profile.php?mode=viewprofile&amp;u=1845&quot; target=&quot;_blank&quot;&gt;lorty&lt;/a&gt; |&lt;br /&gt;
Risposte: 4 |&lt;br /&gt;Messaggio:
&lt;span class="postbody"&gt;Salve devo utilizzare la funzione seekg dell istream:
&lt;br /&gt;

&lt;br /&gt;
       fn.str(&quot;&quot;);
&lt;br /&gt;
        gn.str(&quot;&quot;);
&lt;br /&gt;
        string s2;
&lt;br /&gt;
      
&lt;br /&gt;
        fn &amp;lt;&amp;lt; 1;      
&lt;br /&gt;
        gn &amp;lt;&amp;lt; 2;
&lt;br /&gt;
       
&lt;br /&gt;
        file= &quot;pippo&quot;+fn.str()+&quot;pluto&quot;+gn.str()+&quot;.txt&quot;;
&lt;br /&gt;
        ifstream f2(file.c_str());
&lt;br /&gt;
        f2.seekg (5, ios::end);
&lt;br /&gt;
        getline(f2, s2);
&lt;br /&gt;
        cout &amp;lt;&amp;lt;s2 &amp;lt;&amp;lt;endl;
&lt;br /&gt;
     
&lt;br /&gt;
        f2.close();
&lt;br /&gt;

&lt;br /&gt;
e il file pippo1pluto2.txt termina con
&lt;br /&gt;
55555555555555555555555555rrrrrrrrrrr
&lt;br /&gt;

&lt;br /&gt;
l output non stampa niente.
&lt;br /&gt;
perchè non mi stampa la successione di r ?
&lt;br /&gt;

&lt;br /&gt;
Se invece gli dò f2.seekg (5, ios::begin); allora stampa giustamente la parte finale della prima riga. Ho forse capito male io l'ios::end? non mette il cursore a 5 posizioni prima dell ultimo carattere?
&lt;/span&gt;&lt;br /&gt;
</description>
</item>
<item>
	<title>leggere da file solo ultima riga</title>
	<link>http://cpiupiu.altervista.org/forum/viewtopic.php?p=13096#13096</link>
	<description>Autore: &lt;a href=&quot;http://cpiupiu.altervista.org/forum/profile.php?mode=viewprofile&amp;u=1845&quot; target=&quot;_blank&quot;&gt;lorty&lt;/a&gt; |&lt;br /&gt;
Risposte: 0 |&lt;br /&gt;Messaggio:
&lt;span class="postbody"&gt;Salve, come da titolo, è possibile leggere da un file solo l ultima riga?
&lt;br /&gt;
come devo fare?
&lt;br /&gt;

&lt;br /&gt;
ifstream f(&quot;temp.txt&quot;);
&lt;br /&gt;
string s;
&lt;br /&gt;
int k;
&lt;br /&gt;

&lt;br /&gt;
getline(f, s); 
&lt;br /&gt;
k=atoi(s.c_str()+27);
&lt;br /&gt;

&lt;br /&gt;
è possibile spostare il puntatore fino all ultima riga?
&lt;br /&gt;
mi interessa il 27esimo carattere dell'ultima riga di un file. 
&lt;br /&gt;
Il file non ha una dimensione fissa perchè ogni volta che viene richiamata la funzione, crea un altro file di dimensione diversa ma di cui mi interessa comunuqe solo il 27esimo carattere dell ultima riga.
&lt;br /&gt;

&lt;br /&gt;
Grazie.
&lt;/span&gt;&lt;br /&gt;
</description>
</item>
<item>
	<title>Link di due file dalla linea di comando</title>
	<link>http://cpiupiu.altervista.org/forum/viewtopic.php?p=13092#13092</link>
	<description>Autore: &lt;a href=&quot;http://cpiupiu.altervista.org/forum/profile.php?mode=viewprofile&amp;u=1821&quot; target=&quot;_blank&quot;&gt;Killabee&lt;/a&gt; |&lt;br /&gt;
Risposte: 1 |&lt;br /&gt;Messaggio:
&lt;span class="postbody"&gt;Ciao a tutti, dovrei linkare questi due file chiamando il linker dal prompt dei comandi di visual C++ 2008 (in ambiente DOS):
&lt;br /&gt;

&lt;br /&gt;
r-avg1.cpp
&lt;br /&gt;
&lt;/span&gt;&lt;table cellspacing=&quot;1&quot; cellpadding=&quot;1&quot; border=&quot;0&quot; align=&quot;center&quot;&gt;  &lt;tr&gt;     &lt;td height=&quot;20&quot;&gt;&lt;span class=&quot;genmed&quot;&gt;&lt;b&gt;Codice:&lt;/b&gt;&lt;/span&gt;&lt;/td&gt;    &lt;td align=&quot;right&quot; class=&quot;genmed&quot;&gt;&lt;a name=&quot;cq&quot; href=&quot;#&quot; onClick=&quot;top.codeResizer(this);return false;&quot;&gt;Espandi/Riduci&lt;/a&gt;&lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;    &lt;td colspan=&quot;2&quot; class=&quot;code&quot;&gt;      &lt;div style=&quot;width:546px; height:66px; overflow:auto; white-space:nowrap;&quot;&gt;	  // ---------------------------Primo file------------------------------------
&lt;br /&gt;
#include &amp;lt;iostream&amp;gt;
&lt;br /&gt;
using namespace std;
&lt;br /&gt;

&lt;br /&gt;
int running_avg&amp;#40;int i&amp;#41;;
&lt;br /&gt;
void reset&amp;#40;&amp;#41;;
&lt;br /&gt;

&lt;br /&gt;
int main&amp;#40;&amp;#41; &amp;#123;
&lt;br /&gt;

&lt;br /&gt;
&amp;nbsp; &amp;nbsp;int num;
&lt;br /&gt;

&lt;br /&gt;
&amp;nbsp; &amp;nbsp;do &amp;#123;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;cout &amp;lt;&amp;lt; &amp;quot;Inserire un numero &amp;#40;-1 per uscire, -2 per azzerare&amp;#41;&amp;#58; &amp;quot;;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;cin &amp;gt;&amp;gt; num;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;if&amp;#40;num == -2&amp;#41; &amp;#123;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;reset&amp;#40;&amp;#41;;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;continue;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;#125;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;if&amp;#40;num!=-1&amp;#41;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;cout &amp;lt;&amp;lt; &amp;quot;La media corrente e'&amp;#58; &amp;quot; &amp;lt;&amp;lt; running_avg&amp;#40;num&amp;#41;;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;cout &amp;lt;&amp;lt; '\n';
&lt;br /&gt;
&amp;nbsp; &amp;nbsp;&amp;#125; while&amp;#40;num != -1&amp;#41;;
&lt;br /&gt;

&lt;br /&gt;
&amp;nbsp; system&amp;#40;&amp;quot;pause&amp;quot;&amp;#41;;
&lt;br /&gt;
&amp;nbsp; return 0;
&lt;br /&gt;

&lt;br /&gt;
&amp;#125;      &lt;/div&gt;     &lt;/td&gt;  &lt;/tr&gt;&lt;/table&gt;&lt;span class=&quot;postbody&quot;&gt;
&lt;br /&gt;

&lt;br /&gt;
r-avg2.cpp
&lt;br /&gt;
&lt;/span&gt;&lt;table cellspacing=&quot;1&quot; cellpadding=&quot;1&quot; border=&quot;0&quot; align=&quot;center&quot;&gt;  &lt;tr&gt;     &lt;td height=&quot;20&quot;&gt;&lt;span class=&quot;genmed&quot;&gt;&lt;b&gt;Codice:&lt;/b&gt;&lt;/span&gt;&lt;/td&gt;    &lt;td align=&quot;right&quot; class=&quot;genmed&quot;&gt;&lt;a name=&quot;cq&quot; href=&quot;#&quot; onClick=&quot;top.codeResizer(this);return false;&quot;&gt;Espandi/Riduci&lt;/a&gt;&lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;    &lt;td colspan=&quot;2&quot; class=&quot;code&quot;&gt;      &lt;div style=&quot;width:546px; height:66px; overflow:auto; white-space:nowrap;&quot;&gt;	  // -----------------------------Secondo file------------------------------
&lt;br /&gt;

&lt;br /&gt;
static int sum = 0, count = 0;
&lt;br /&gt;

&lt;br /&gt;
int running_avg&amp;#40;int i&amp;#41;
&lt;br /&gt;
&amp;#123;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp;sum = sum+i;
&lt;br /&gt;

&lt;br /&gt;
&amp;nbsp; &amp;nbsp;count++;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp;return sum / count;
&lt;br /&gt;
&amp;#125;
&lt;br /&gt;

&lt;br /&gt;
void reset&amp;#40;&amp;#41;
&lt;br /&gt;
&amp;#123;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp;sum = 0;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp;count = 0;
&lt;br /&gt;
&amp;#125;      &lt;/div&gt;     &lt;/td&gt;  &lt;/tr&gt;&lt;/table&gt;&lt;span class=&quot;postbody&quot;&gt;
&lt;br /&gt;

&lt;br /&gt;
Come vedete in r-avg1.cpp vengono dichiarate e chiamate le funzioni &lt;span style=&quot;font-weight: bold&quot;&gt;run_avg()&lt;/span&gt; e &lt;span style=&quot;font-weight: bold&quot;&gt;reset()&lt;/span&gt;, le quali vengono definite nel file r-avg2.cpp.
&lt;br /&gt;
Per risolvere i riferimenti esterni in r-avg1.cpp ho provato a dare queste due istruzioni sulla linea di comando:
&lt;br /&gt;

&lt;br /&gt;
&lt;span style=&quot;color: darkred&quot;&gt;link r-avg1.cpp r-avg2.cpp&lt;/span&gt; (chiamo solo il linker)
&lt;br /&gt;
&lt;span style=&quot;color: darkred&quot;&gt;cl -EHsc r-avg1.cpp /link r-avg2.cpp&lt;/span&gt; (chiamo compilatore e linker).
&lt;br /&gt;

&lt;br /&gt;
Quello che ottengo sono dei messaggi di errore. Nel primo caso ho
&lt;br /&gt;

&lt;br /&gt;
&lt;span style=&quot;color: darkred&quot;&gt;r-avg1.cpp: fatal error LNK1107: file danneggiato o non valido: impossibile leggere in 0x204&lt;/span&gt;,
&lt;br /&gt;

&lt;br /&gt;
mentre nel secondo mi dice
&lt;br /&gt;

&lt;br /&gt;
&lt;span style=&quot;color: darkred&quot;&gt;r-avg2.cpp: fatal error LNK1107: file danneggiato o non valido: impossibile leggere in 0x103&lt;/span&gt;.
&lt;br /&gt;

&lt;br /&gt;
I messaggi di errore sono praticamente gli stessi ma non capisco cosa non vada bene... Forse può essere utile sapere come le due istruzioni richiedono di essere impiegate:
&lt;br /&gt;

&lt;br /&gt;
&lt;span style=&quot;color: darkred&quot;&gt;LINK [opzioni] [file] [@commandfile]&lt;/span&gt;;
&lt;br /&gt;
&lt;span style=&quot;color: darkred&quot;&gt;cl [opzione...] nomefile... [/link opzione di collegamento...]&lt;/span&gt;.
&lt;br /&gt;

&lt;br /&gt;
Ho già cercato su internet a riguardo, specialmente nella documentazione ufficiale del compilatore, ma non ho trovato spiegazioni esaurienti...
&lt;br /&gt;
Spero di aver descritto bene il mio problema e soprattutto che qualcuno mi aiuti!  &lt;img src=&quot;http://cpiupiu.altervista.org/forum/images/smiles/icon_cry.gif&quot; alt=&quot;Crying or Very sad&quot; border=&quot;0&quot; /&gt;
&lt;/span&gt;&lt;br /&gt;
</description>
</item>
</channel>
</rss>

