When your question is answered use !solved to mark the question as resolved.
Remember to ask specific questions, provide necessary details, and reduce your question to its simplest form. For tips on how to ask a good question use !howto ask.
25 messages · Page 1 of 1 (latest)
When your question is answered use !solved to mark the question as resolved.
Remember to ask specific questions, provide necessary details, and reduce your question to its simplest form. For tips on how to ask a good question use !howto ask.
!solved
Thank you and let us know if you have any more questions!
This thread is now set to auto-hide after an hour of inactivity
people's FILE is color coded and mine isn't
That's likely just because you use a different extension (or sometimes restarting VS Code solves this already)
thank you im just trouble shooting a different problem now
trying to format the output correctly and figure out why im getting numbers that arent magnitudes and negative averages
this is what my output looks like now
any tips
!sc
@lapis terrace
They're hard to read and prevent copying and pasting.
okay how do i post code in that formatted way everyone does
!code
```c
int main() {}
```
int main() {}
fgets(line, sizeof(line), fp);
while (fgets(line, sizeof(line), fp) != NULL) {
char *token = strtok(line, ",");
char time[50], place[100];
float latitude = 0.0, longitude = 0.0, magnitude = 0.0, cost = 0.0;
int column = 0;
while (token != NULL) {
switch (column) {
case 0:
strcpy(time, token);
break; // time
case 1:
latitude = atof(token);
break; // Latitude
case 4:
magnitude = atof(token);
break; // Magnitude
case 13:
strcpy(place, token);
break; // Place
}
token = strtok(NULL, ",");
column++;
}
count++;
sum += magnitude;
cost = magnitude * BASELINE;
// Print the current row
printf("\t%30s %10.2f $%14.2f %-30s\n", time, magnitude, cost, place);
backtick not single quotation (back tick same as the tilde key ~)
ur using apostrophe
thank you guys lmao sorry
Okay, what about the output is wrong for you now?
its reading the longitude from the csv file and i want it to read the magnitude
Program enhanced by Mohamed G - Saturday 8/3/24 Time Magnitude Cost Place
2024-08-03T04:20:26.609Z 126.76 $126763600.00 "36 km E of Barcelona
2024-08-02T22:23:01.342Z 126.60 $126600000.00 "18 km ENE of Barcelona
2024-07-29T20:00:52.590Z -116.79 $-116786664.00 "22 km ENE of Barstow
2024-07-29T05:29:05.760Z -112.85 $-112852336.00 "24 km S of Brian Head
2024-07-26T14:28:29.143Z -100.66 $-100659000.00 "17 km NNE of Hermleigh
2024-07-23T03:38:42.943Z -100.66 $-100659000.00 "17 km NNE of Hermleigh
2024-07-22T19:19:34.604Z -82.84 $-82841200.00 "5 km SSE of Puerto Armuelles
2024-07-21T02:53:48.692Z -89.90 $-89904400.00 "7 km SW of San Pedro Pinula
2024-07-19T01:50:47.675Z -67.78 $-67781800.00 "45 km ESE of San Pedro de Atacama
2024-07-11T15:08:47.501Z -128.73 $-128725400.00 "209 km WSW of Tofino
2024-07-11T02:13:17.720Z 123.15 $123154800.00 "105 km WSW of Sangay
2024-07-10T04:55:41.773Z 25.36 $25361000.00 "south of Africa"