primero que todo usa GESHI para que se vea mejor el codigo y se mas legible
segundo trata de inicializar las variables antes de usarlas ,
segundo trata de inicializar las variables antes de usarlas ,
Esta sección te permite ver todos los mensajes escritos por este usuario. Ten en cuenta que sólo puedes ver los mensajes escritos en zonas a las que tienes acceso en este momento.
Mostrar Mensajes Menú char *addComma(char *szValue){
char *szReturn = NULL;
char *szTemp1 = NULL;
char *szTemp2 = NULL;
int inLength = strlen(szValue);
/*
* 10000.00 -->> 10,000.00
* 9000.00 -->> 9,000.00
*
*
*
* */
if(inLength >= 6 ){
switch(inLength){
case 7:
strncpy(szTemp1,szValue, 2 );
strncat(szTemp1, ",", 1);
strncat(szTemp1, szValue+3,3);
strncpy(szTemp1, ".", 1);
break;
case 5:
}
}
return szTemp1;
}
<xml>
<tag>
m texyo de be ser
ffgfgf
fgfhfhfh
hf hhf hf hf hfh
gh hghg gh ghghg
gh ghgh
</tag>
</xml>
#include <fcntl.h>
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
int main(int argc ,char argv[])
{
int bucle =0;
char *pbuffer={'\0'};
int file = open("s.xml", O_RDONLY);
if(file < 0){
printf("Error Abriendo el fichero \n");
exit(1);///salida de error
}else{
pbuffer = NULL;
int r = read(file, 1024);
printf("cantidad de bytes leidos :\n %d", r);
close(file);
char *sin= strstr(pbuffer, "<tag>");
pbuffer = NULL;
while(sin[5+bucle] != '<')
{
strncat(pbuffer, &sin[5+bucle],1);
bucle++;
}
int s2 = open("copia.xml", O_WRONLY|O_TRUNC);
if(s2 < 0){
printf("Error @");
int d= write(sin, 1024);
printf("cantidad de bytes escritos : %d", d);
close(s2);
}
}///else??
}
#include<fcntl,h>
char buffer[1024];
int main()
{
int fd = open("buffe.cier", O_WRONLY);
if(fd < 0)
{
///error
}else{
////aqui la verdad no me llega como llenar el buffer
//// pense usar un while o un for para ir leyendo
//// pero es un sistema empotrado
////intente leer 1024 a 1024
////2048 a 2018
///// y tambien el buffer completo
/// 11700 pero nada
///////opiniones!!! please
}
return 0;
}
char datos[] ="SOLOESTO..0000000000000000000 0000000 000000000 0000.0 00000-00-10011:00:00 ";
int main(){
char *b;
b =(char*)malloc(1000);
for(int i= 0; i < strlen(datos); i++)
if( i < 10)
strncat(b, &datos[i],1);
cout<<b;
free(b);
}
while( (ptr = strtok( NULL, s2 )) != NULL ) // Posteriores llamadas
strncat(s, ptr,20);
_CRTIMP char* __cdecl __MINGW_NOTHROW strncat (char*, const char*, size_t);
#include <iostream>
#include <cstring>
#include <cstdlib.h>
using namespace std;
struct Campos {
char campo1[10];//10
char campo2[16];
char campo3[7];
char campo4[8];
char campo5[6];
char campo6[21];
};
char datos[] ="SOLOESTO..0000000000000000000 0000000 000000000 0000.0 00000-00-10011:00:00 ";
int main(){
Campos cmp1;
memset(&cmp1, 0x00, sizeof(Campos));
char token2[2000];
char *token = strtok(datos , " ");
while(token != NULL)
{
cout << " "<<endl<< token;
/////AQUI
strcat(token2, token );
token=strtok(NULL, " ");
strcat(token2, token );
//// AQUI ....
}
cout <<token2;
cout<< " token : \n"<<token<<endl;
cout << "\niteraciones ----------------------------------------";
for(int iteraciones= 0; iteraciones < 11; iteraciones++)
{
if(iteraciones < 11)
{
strncat(cmp1.campo1,token[iteraciones], 1);////en esta iteracion solo quiero copiar un caracter
cout << cmp1.campo1;
}
}
}
Me asegure de darle 2000 campos para ver si no falla pero falla como quiera.