October 21, 2024
Chicago 12, Melborne City, USA
C#

How to emulate a do-while loop?

Is there a Python equivalent of do… while loop? Python has try…except loop, while True loop, etc. I have tried anything but no one corrects C: int main { int y; do { scanf("%d",&y); } while (y>0); return 0; } You need to sign in to view this answers

Read More
C#

C/C++ Visual Studio code

does not exist yet. even though i followed the instructions i need help pelisse. i don’t know if this is the correct outcome but after i followed the instructions from https://code.visualstudio.com/docs/cpp/config-mingw it doesn’t work enter image description hereenter image description here help me pls i tried restarting and redownload msys2 multiple times and it didn’t

Read More
C#

confusion with fseek() in C

I am new to the C programming language. I am learning file I/O, and am confused with the fseek function. Here is my code #include <stdio.h> #include <stdlib.h> struct threeNumbers { int n1, n2, n3; } int main () { int n; struct threeNumbers number; FILE *filePointer; if ((filePointer = fopen("\\some_folder\program.bin", "rb")) == NULL) {

Read More
C#

Could the LLDPDUs constructed by the 1905.1 to be disable?

I am fairly new to network programming. I am working on an implementation of IEEE1905.1 in C. I understand that it would also construct the LLDPDUs. But it would happen that the neighbor would receive two LLDPDU with the same Chassis ID and Port ID. So that the LLDP remote table would be changed while

Read More
C#

Why do we need a null terminator only in strings in C?

I’m taking CS50X. I’m on week 2 now. my question is: why do we need a null character ‘\0’ in strings (aka null terminated char arrays) to mark its end, while we don’t need it in normal char arrays or a non-string data type array such as an int array , like while printing both

Read More
C#

How to account for destination being file or directory in cp implementation in c

I am writing a pseudo-shell in c for a class and my cp command needs to account for the destination being a file or a directory. I realized after I implemented everything I currently only truly account for a file name as destinationPath. How should I go about accounting for that? void copyFile(char *sourcePath, char

Read More
C#

Transferring output of a program to a file in C

I have written a C program to get all the possible combinations of a string. For example, for abc, it will print abc, bca, acb etc. I want to get this output in a separate file. What function I should use? I don’t have any knowledge of file handling in C. If somebody explain me

Read More
C#

Undefined Reference? But I've already implemented the function

display.h #ifndef PRO_DISPLAY_H #define PRO_DISPLAY_H /** Initializes the display **/ int pro_display_init(void); #endif /* PRO_DISPLAY_H */ display.c #include "main.h" static int height_ = 300; static int width_ = 300; static int bpp_ = 16; static SDL_Surface* screen_ = NULL; int pro_display_init(void) { screen_ = SDL_SetVideoMode(width_, height_, bpp_, SDL_HWSURFACE|SDL_DOUBLEBUF); if (!screen_) { pro_sdl_error("Video initialization failed."); return

Read More
C#

Get sizeof anonymous struct inside union

I’m hoping this isn’t a duplicate question, but I’ve searched in some detail and haven’t found my exact case before. I have a simple struct that I also want to be able to access as a simple byte array union { struct { unsigned char a; unsigned char b; // ... Some other members ...

Read More
C#

How to get the payload of paged data in skb?

I’m trying to implement a netfilter module and in process of debugging TCP packets, I found out that the payload part was missing in skb->data. I believe it might have something to do with the data being paged. for(int i = 0; i < skb->len; i++) { printk(KERN_CONT "%02x\t", skb->data[i]); } To present the example

Read More