no, puntatore non è null, il problema che non puoi scrivere parti di stringa allocata staticamente perchè si trova nella memoria protetta
codice:
#include <stdio.h>
#include <string.h>
#include <iostream>
using namespace std;
int main ()
{
//dichiarazione delle variabili
int i;
char temp[20];
char *tmp = temp;
char *puntatore;
char *str = new char[20];
strcpy(str,"PROVA DI SCRITTURA");
int lunghezza;
lunghezza=strlen(str);
cout << "Stringa inserita:\t " << str << endl;
cout << "Lunghezza stringa:\t " << lunghezza << endl;
puntatore = strstr (str,"DI");
strncpy (puntatore," ",2);
while ( *str ) {
if ( !isspace ( *str ) ) {
*tmp = *str;
tmp++;
}
str++;
}
*tmp = '\0';
cout << temp << endl;
return ( 0 ) ;
}
così funziona perchè è allocata dinamicamente, anche se non pulisce la memoria, ma lo correggi tu.
ciao
sergio