Just starting out? Need help? Post your questions and find answers here.
Kwai chang caine
Always Here
Posts: 5353 Joined: Sun Nov 05, 2006 11:42 pm
Location: Lyon - France
Post
by Kwai chang caine » Mon May 31, 2021 4:48 pm
Hello at all
I search to read in PB, the string result of C function, without succes
The PrintF direct function and passing by variable works, but the debug of the char* return nothing
Code: Select all
! char* StringC()
! {
! static char v_chaine[4];
! v_chaine[0] = 'K';
! v_chaine[1] = 'C';
! v_chaine[2] = 'C';
! v_chaine[3] = '\0';
! char v_chaine2[] = " and PB";
! strcat(v_chaine, v_chaine2);
! return v_chaine;
! }
! printf("%s\n", StringC());
! char* Mystring = StringC();
! printf("%s\n", Mystring);
Debug PeekS(@Mystring, 30, #PB_Ascii)
If someone know how ?
Have a good day
Last edited by
Kwai chang caine on Mon May 31, 2021 6:24 pm, edited 1 time in total.
The happiness is a road...
Not a destination
Keya
Addict
Posts: 1891 Joined: Thu Jun 04, 2015 7:10 am
Post
by Keya » Mon May 31, 2021 4:59 pm
Post the output of the C code
perhaps youre just missing "v_" eg "v_Mystring"
Kwai chang caine
Always Here
Posts: 5353 Joined: Sun Nov 05, 2006 11:42 pm
Location: Lyon - France
Post
by Kwai chang caine » Mon May 31, 2021 5:05 pm
Hello KEYA, thanks for your interest
Code: Select all
//
// PureBasic 6.00 Alpha 1 - C Backend (Windows - x64) generated code
//
// (c) 2021 Fantaisie Software
//
// The header must remain intact for Re-Assembly
//
// :System
//
#pragma warning(disable: 4024)
//
typedef long long quad;
typedef quad integer;
typedef struct pb_array { void *a; } pb_array;
typedef struct pb_array2 { void *a; integer b[2]; } pb_array2;
typedef struct pb_array3 { void *a; integer b[3]; } pb_array3;
typedef struct pb_array4 { void *a; integer b[4]; } pb_array4;
typedef struct pb_array5 { void *a; integer b[5]; } pb_array5;
typedef struct pb_array6 { void *a; integer b[6]; } pb_array6;
typedef struct pb_array7 { void *a; integer b[7]; } pb_array7;
typedef struct pb_array8 { void *a; integer b[8]; } pb_array8;
typedef struct pb_array9 { void *a; integer b[9]; } pb_array9;
typedef struct pb_listitem { void *a; void *b; void *c;} pb_listitem;
typedef struct pb_list { void *a; pb_listitem *b; } pb_list;
typedef struct pb_mapitem { void *a; void *b; void *c;} pb_mapitem;
typedef struct pb_pbmap { pb_mapitem *a; } pb_pbmap;
typedef struct pb_map { pb_pbmap *a; } pb_map;
static integer s_s[]={0, -1};
#define M_SYSFUNCTION(a) a __stdcall
#define M_PBFUNCTION(a) a __stdcall
#define M_CDECL
typedef void TCHAR;
static integer SYS_BankerRound(double i) { return i >= 0 ? i+0.5 : i-0.5; }
integer __stdcall ExitProcess(integer);
integer __stdcall HeapCreate(integer,integer,integer);
integer __stdcall HeapDestroy(integer);
integer __stdcall GetModuleHandleW(integer);
//
static char *tls;
//
//
//
//
void SYS_Quit();
//
integer ms_s[]={0,-1};
//
//
//
char PB_OpenGLSubsystem=0;
int PB_DEBUGGER_LineNumber=-1;
int PB_DEBUGGER_IncludedFiles=0;
char *PB_DEBUGGER_FileName=0;
int PB_Compiler_Unicode=1;
int PB_Compiler_Thread=0;
int PB_Compiler_Purifier=0;
int PB_Compiler_Debugger=0;
int PB_Compiler_DPIAware=0;
int PB_Compiler_XPSkins=0;
int PB_ExecutableType=0;
//
integer PB_MemoryBase=0;
integer PB_Instance=0;
int PB_ExitCode=0;
//
void PB_EndFunctions() {
}
//
void ___chkstk_ms(integer a) { return; }
int __stdcall WinMain(void *instance, void *prevInstance, void *cmdLine, int cmdShow) {
PB_Instance = GetModuleHandleW(0);
PB_MemoryBase = HeapCreate(0,4096,0);
//
//
// ! const char* StringC()
const char* StringC()
// ! {
{
//
// ! static char* v_chaine[4];
static char* v_chaine[4];
// ! v_chaine[0] = 'K';
v_chaine[0] = 'K';
// ! v_chaine[1] = 'C';
v_chaine[1] = 'C';
// ! v_chaine[2] = 'C';
v_chaine[2] = 'C';
// ! v_chaine[3] = '\0';
v_chaine[3] = '\0';
//
// ! char v_chaine2[] = " and PB";
char v_chaine2[] = " and PB";
// ! strcat(v_chaine, v_chaine2);
strcat(v_chaine, v_chaine2);
//
// ! return v_chaine;
return v_chaine;
//
// ! }
}
//
// ! printf("%s\n", StringC());
printf("%s\n", StringC());
//
// ! const char* Mystring = StringC();
const char* Mystring = StringC();
// ! printf("%s\n", Mystring);
printf("%s\n", Mystring);
//
// Debug PeekS(@Mystring, 30, #PB_Ascii)
SYS_Quit();
}
void SYS_Quit() {
PB_EndFunctions();
HeapDestroy(PB_MemoryBase);
ExitProcess(PB_ExitCode);
}
The happiness is a road...
Not a destination
chi
Addict
Posts: 1034 Joined: Sat May 05, 2007 5:31 pm
Location: Linz, Austria
Post
by chi » Mon May 31, 2021 6:17 pm
With the proper prefix and all letters of the variable in lower case...
Code: Select all
! char* StringC()
! {
! static char v_chaine[4];
! v_chaine[0] = 'K';
! v_chaine[1] = 'C';
! v_chaine[2] = 'C';
! v_chaine[3] = '\0';
! char v_chaine2[] = " and PB";
! strcat(v_chaine, v_chaine2);
! return v_chaine;
! }
! printf("%s\n", StringC());
! char* v_mystring = StringC();
! printf("%s\n", v_mystring);
Debug PeekS(MyStRiNg, -1, #PB_Ascii)
Et cetera is my worst enemy
chi
Addict
Posts: 1034 Joined: Sat May 05, 2007 5:31 pm
Location: Linz, Austria
Post
by chi » Mon May 31, 2021 7:05 pm
Et cetera is my worst enemy