این اضافه کردم ولی خطا همچنان باقی است ممنون
unsigned char Buffer;
unsigned char Buffer;
cError: C:\Users\FLIGHTSAZAN-AIRSHIP\Documents\test1.c(93): must declare first in block
char Buffer[20] = "SS 235.23g";
cError: C:\Users\FLIGHTSAZAN-AIRSHIP\Documents\test1.c(93): must declare first in block
char Buffer[20] = "SS 235.23g";
printf("%.3f\n", Weight);

[FONT=Yekan]||=== Build: Debug in tc13 (compiler: GNU GCC Compiler) ===|[/FONT]C:\Users\FLIGHTSAZAN-AIRSHIP\Documents\tc13\main.c|11|warning: data definition has no type or storage class|
C:\Users\FLIGHTSAZAN-AIRSHIP\Documents\tc13\main.c|11|warning: type defaults to 'int' in declaration of 'result' [-Wimplicit-int]|
C:\Users\FLIGHTSAZAN-AIRSHIP\Documents\tc13\main.c|11|error: initializer element is not constant|
C:\Users\FLIGHTSAZAN-AIRSHIP\Documents\tc13\main.c|12|error: expected identifier or '(' before 'if'|
||=== Build failed: 2 error(s), 2 warning(s) (0 minute(s), 0 second(s)) ===|
[FONT=Yekan]#include <stdio.h>[/FONT]#include <stdlib.h>
//using namespace std;
int main(void)
{
char *string = "ss 223.34g", *ptr = string;
while (*ptr) {
if (isdigit(*ptr) ) {
float val = strtof(ptr, &ptr);
if (ceilf(val) == val) {
printf("%.0f\n", val);
} else {
printf("%.3f\n", val);}
} else {
ptr++;
}
}
return 0;
}
[FONT=Yekan]#include <stdio.h>[/FONT]#include <stdlib.h>
//using namespace std;
int main(void)
{
char *string = "ss 223.34g", *ptr = string;
while (*ptr) {
if (isdigit(*ptr) ) {
float val = strtof(ptr, &ptr);
if (ceilf(val) == val) {
printf("%.0f\n", val);
} else {
printf("%.3f\n", val);}
} else {
ptr++;
}
}
return 0;
}
[FONT=Yekan]||=== Build: Debug in tc13 (compiler: GNU GCC Compiler) ===|[/FONT]C:\Users\FLIGHTSAZAN-AIRSHIP\Documents\tc13\main.c|11|warning: data definition has no type or storage class|
C:\Users\FLIGHTSAZAN-AIRSHIP\Documents\tc13\main.c|11|warning: type defaults to 'int' in declaration of 'result' [-Wimplicit-int]|
C:\Users\FLIGHTSAZAN-AIRSHIP\Documents\tc13\main.c|11|error: initializer element is not constant|
C:\Users\FLIGHTSAZAN-AIRSHIP\Documents\tc13\main.c|12|error: expected identifier or '(' before 'if'|
||=== Build failed: 2 error(s), 2 warning(s) (0 minute(s), 0 second(s)) ===|
[FONT=Yekan]#include <stdio.h>[/FONT]#include <stdlib.h>
int main()
{
char Buffer[20] = "SS 0.0g";
float Weight = 0f;
int result;
result = sscanf(Buffer, "SS %fg", &Weight);
if (result == 1);
{
// Success
}
return 0;
}
[FONT=Yekan]#include <stdio.h>[/FONT]#include <stdlib.h>
int main()
{
char Buffer[20] = "SS 0.0g";
float Weight = 0f;
int result;
result = sscanf(Buffer, "SS %fg", &Weight);
if (result == 1);
{
// Success
}
return 0;
}
یک دیدگاه بنویسید: