How to avoid the space in character array using C
-
Hi, struct Boxinfo { int userid; char username[255]; }; if ((Boxinfo_ptr =(struct Boxinfo *) malloc(sizeof(struct Boxinfo))) == 0) { exit(1); } EXEC SQL FETCH customerinfo INTO: Boxinfo_ptr; cout<<Boxinfo_ptr->userid; cout<<Boxinfo_ptr->username; here i have fetch the record from database two field then load to struct object Boxinfo_ptr no problem. also successfully i have got the value of userid and username . My problem is Boxinfo_ptr->username is given the extra space . that is suppose charter is "hello" for cout<<Boxinfo_ptr->username this output is "hello " it is simple print hello+200 space; so how to avoid 200 space. example: input: userid=100; username="hello"; output: userid=100; username="hello " How to avoid space for username char array. please replay me as soon as possible Thanks
-
Hi, struct Boxinfo { int userid; char username[255]; }; if ((Boxinfo_ptr =(struct Boxinfo *) malloc(sizeof(struct Boxinfo))) == 0) { exit(1); } EXEC SQL FETCH customerinfo INTO: Boxinfo_ptr; cout<<Boxinfo_ptr->userid; cout<<Boxinfo_ptr->username; here i have fetch the record from database two field then load to struct object Boxinfo_ptr no problem. also successfully i have got the value of userid and username . My problem is Boxinfo_ptr->username is given the extra space . that is suppose charter is "hello" for cout<<Boxinfo_ptr->username this output is "hello " it is simple print hello+200 space; so how to avoid 200 space. example: input: userid=100; username="hello"; output: userid=100; username="hello " How to avoid space for username char array. please replay me as soon as possible Thanks
The reason it gives you 200 spaces may be because of the field properties you have set in your database. You might have set it as fixed length string field of size 255. Try to make it a variable length string field.
cheers Varghese Paul
-
The reason it gives you 200 spaces may be because of the field properties you have set in your database. You might have set it as fixed length string field of size 255. Try to make it a variable length string field.
cheers Varghese Paul
Not possible to set variable length string because database object is return struct variable with fixed length character using pro*C. suppose i have try to declare structure member variable like character pointer or void pointer when it return memory leak . I have developed this application using Pro *C language.
-
The reason it gives you 200 spaces may be because of the field properties you have set in your database. You might have set it as fixed length string field of size 255. Try to make it a variable length string field.
cheers Varghese Paul
Not possible to set variable length string because database object is return struct variable with fixed length character using pro*C. suppose i have try to declare structure member variable like character pointer or void pointer when it return memory leak . I have developed this application using Pro *C language.
-
Not possible to set variable length string because database object is return struct variable with fixed length character using pro*C. suppose i have try to declare structure member variable like character pointer or void pointer when it return memory leak . I have developed this application using Pro *C language.
Is this a case of split personallity or did you just change your name :confused:
Bram van Kampen