c99

Implicit declaration of scandir; alphasort is undeclared

三世轮回 提交于 2019-12-13 16:26:39
问题 I am trying to use scandir to print a list of files in the current directory. When I try to compile, I am receiving the following errors and warnings: warning: implicit declaration of function ‘scandir’ [-Wimplicit-function-declaration] error: ‘alphasort’ undeclared (first use in this function) note: each undeclared identifier is reported only once for each function it appears in I am including <dirent.h> , which to my knowledge should define scandir() and all related functions. And I don't

Does this function I made correctly append a string to another string?

橙三吉。 提交于 2019-12-13 11:17:15
问题 I was up coding at 3 AM last night, and I wake up today and find this in a source file: (curse words redacted) void append_this_stuff(char *stuff_to_append_to[], char **stuff_to_append, int position) { char the_actual_stuff[] = *(stuff_to_append_to); char *screw_me = *(stuff_to_append); int someNumber = strlen(screw_me); int j = 0; for (int i = position; i < (someNumber + position - 1); i++) { the_actual_stuff[i] = (screw_me + j); j++; } stuff_to_append_to = &the_actual_stuff; } When I try to

Still able to access a struct that has been freed [duplicate]

非 Y 不嫁゛ 提交于 2019-12-13 10:54:41
问题 This question already has answers here : Why freed struct in C still has data? (7 answers) Closed 5 years ago . So, I have a struct: tyepdef struct node { struct node *next; double value; } NodeT, *NodeTP; and I have three functions: int deleteNode(NodeTP p) { free(p); p = NULL; return 1; } int deleteOne(NodeTP list) { if (list->next != NULL) deleteOne(list->next); else deleteNode(list); return 1; } int print(NodeT list) { printf("%lf\n", list.value); if (list.next != NULL) print(*list.next);

Why is fgets getting stuck on carriage return \r?

限于喜欢 提交于 2019-12-13 08:35:53
问题 I'm new to the forum and to c in general, so please bear with me. I'm trying to write a c program that takes a text file and parses all words and characters, then saves them to an output text file. I'm using C99, Windows 7-64bit, MinGW, notepad, notepad++, and ASNI format for txt files. I've read that fgets() is better to use than fscanf for reading input because it has buffer overflow protection, so I decided to try using it, but it's having issues with some punctuation in the test file (I

Write to separate files with different file names

梦想的初衷 提交于 2019-12-13 07:29:22
问题 This is what I am trying to achieve: Assume the user inputs are: Generating random instances ... Enter the circuit board size MAX_X MAX_Y: 100 200 Enter the number of points NUM_PT: 10 Enter the number of random instances to be generated: 7 your program will generate in total 7 instances, written into 7 separate files "instance10_j.txt", for j = 1, 2, 3, ... Each instance has the rectangular area [0 ; 100] X [0 ; 200], and has 10 points. The coordinates of a point is generated uniformly

How to save the result of typeof? [closed]

流过昼夜 提交于 2019-12-13 07:24:14
问题 Closed . This question needs details or clarity. It is not currently accepting answers. Want to improve this question? Add details and clarify the problem by editing this post. Closed 2 years ago . I am a new programmer that is mostly using Code::Blocks for C 99 . I recently found out about the typeof() because it was hidden as __typeof __() and I wanted to know if you can save a type as a result of typeof. something like: type a = __typeof__(?); Or #define typeof __typeof__ type a = typeof(?

Is there a reason why NOT to force 8-byte alignment for complex float type?

[亡魂溺海] 提交于 2019-12-13 03:38:23
问题 This is a follow-up for this question. We have an implementation of GCC for our embedded architecture. As such we have control over some aspects of the compiler and optimizer. Such aspect may be potentially forcing the 8-byte aligned allocation of complex float objects. Generally speaking, on our architecture we can optimize access to these objects if they are properly aligned, by requiring a single double-load instruction instead of two regular loads. Just before a round of enhancements and

Is (x++, y) + (y++, x) undefined or unspecified, and if unspecified, what can it compute?

三世轮回 提交于 2019-12-13 02:35:19
问题 The comma sequence operator introduces a sequence point in an expression. I am wondering whether this means that the program below avoids undefined behavior. int x, y; int main() { return (x++, y) + (y++, x); } If it does avoid undefined behavior, it could still be unspecified, that is, return one of several possible values. I would think that in C99, it can only compute 1 , but actually, various versions of GCC compile this program into an executable that returns 2 . Clang generates an

What does the ISO/IEC 9899 6.8.4.2 ->2 phrase mean? [duplicate]

五迷三道 提交于 2019-12-13 00:00:37
问题 This question already has answers here : Explanation of switch statement constraints on variably modified types in C standard (3 answers) Closed 3 months ago . I don't get it what this means. I already thought this could mean code as in my code snippet of this Question: Skipping switch cases via false loop is a valid operation? But as the answerers just where going to improve the code and ignored my question about the c99 quote, I'm going to ask this here now explicitly: If a switch statement

Has anyone implemented __getzone() for IAR Embedded Workbench for MSP430?

梦想的初衷 提交于 2019-12-12 20:00:05
问题 I am having to deal with some time conversions in my application. I would like to stick to using standard library functions as much as possible. Right now I am using a time_t structure as my system time base. However, some devices can sync time to my device, and that time may or may not be UTC. Also, my device will sync time to another device and that time WILL always be UTC. Anyway, I can ask the user what the time zone is of the time that is being synced to my device and whether or not they