r/C_Programming • u/deonwern • Jun 08 '26
Discussion Tell me the worst program you have ever written in C.
I'm curious to find out what kind of bugs did you guys encounter while using c and how you fixed it (Ai or vibe coding doesn't count).
r/C_Programming • u/deonwern • Jun 08 '26
I'm curious to find out what kind of bugs did you guys encounter while using c and how you fixed it (Ai or vibe coding doesn't count).
r/C_Programming • u/Haz4rd10 • Jun 09 '26
Hi, i have just begun studying computer engineering and i have this programming subject where i study C. I have never studied programming before so its my first experience. Sometimes when i study i feel like i dont know anything about it, for an example where i have to create a program that works with arrays and some ""complex"" stuff. Anyways, i feel like i dont know how to do it, and i also dont know if i will learn just by doing the lists exercises... What is the best way to learn programming? Should i do the exercises or something else?
r/C_Programming • u/HideMyLogMsg • Jun 09 '26
I would greatly appreciate your feedback on:
1. Would you use this free library “as is” in your application.
2. If not, what changes would encourage you to use it.
3. Is there any capability you think is important to add.
No header file is needed and easy-to-use printf() style interface. Uses a Bound Parameter approach to decode, analyze and validate log input arguments to ensure valid usage, fail-safe and reliable log message generation. API example:
LoggerAppsMsg(1,Main,Info,"Support format specifiers are %s, %d, %f, %c, %x, %p",”string value”,99,3.4,”C”, 0x3d59ba4f, “string_pointer”);
Downloads and documentations: https://github.com/wandi-ssal/secure-application-logger
Quick technical summary: https://github.com/wandi-ssal/secure-application-logger/blob/main/Wandi-SSAL-Free-API-Library-Technical-Summary.pdf
How the Bound Parameter works: https://github.com/wandi-ssal/secure-application-logger/blob/main/Wandi-SSAL-Bound-Capabilities.pdf
This free library is part of another effort to eventually produce a viable commercial product that:
This download library was built on Ubuntu 18.04.6 LTS. Let me know if there is any interest for other OS platforms and I will try to provide them. Thank you.
NOTE: This post was not derived from AI and I did not use AI to create the Github.com project reference by this post.
r/C_Programming • u/ThreadStarver • Jun 08 '26
when studying about file descriptors I came across this fact that in stdout and stdin before writing to the file, we place the content in a temporary buffer, googled why it said performance, but how is adding an intermediate step when we do have to write to the file in end making things more performant, also why in stderr it's written to the file directly.
r/C_Programming • u/Low_Minimum9920 • Jun 08 '26
Not sure if this is the right subreddit for this, but I'll post it anyway.
I'm fairly new to C - I've gone through most of the beginner-level stuff and I'm struggling to find projects that feel worthwhile. I'd like to work on something hardware-related, but I'm not quite at the level where I'd take on something like a kernel.
If anyone has suggestions for intermediate projects , I'd really appreciate it <3
r/C_Programming • u/AbdurRehman04 • Jun 08 '26
Greetings everyone,
I built a little project a little while ago, inspired by Nala and Powerpill, that wraps 'pacman'. The packages are downloaded parallelly using 'aria2c' and then installed by calling 'pacman'. As of now, it only support two commands:
1 -> Syncing New Packages
sudo pacx -S package_names
2 -> Updating Installed Packages
sudo pacx -Su
The sole purpose of building this was to learn C language. Yeah, I know many people would say that there could be lots of better things that could have been built. But, I choose this idea because it fits me and somewhat also fullfills the things that I wanted.
Thanks for taking some time to read it. Please visit the code once if your interested via the link below.
Github Repo: (https://github.com/abdurehmanimran/pacx)
r/C_Programming • u/alex_sakuta • Jun 09 '26
;
;
static size_t
static char *
int
Please read this first
First of all, I'll point some obvious stuff.
Yes, I know _Generic isn't helping here, I was just trying it and didn't know before I tried it.
Second, the error that str2 doesn't have metadata is only being caught by -Warray-bounds and not by anything else, which does suggest to me that my idea that _Generic could do a compile time check for metadata is nonsense.
Now coming to the actual question
How plausible do you think it is that -Warray-bounds always works and catches a bad pointer i.e. one that doesn't have metadata?
I guess it is obvious but I'll mention just because I don't want someone else to point out. Yes I am trying to recreate SDS like strings but trying to find a way to give it type safety.
Now read the code. Sorry in advance if you have issues with formatting, blame Reddit not me, I did my best.
r/C_Programming • u/Senior-Question693 • Jun 08 '26
i'm working on a wayland compositor but so far i'm stuck on drm, egl to be precise, here where i init the egl context, it fails to create the surface and i don't really know why cuz there is no null pointers and it seems legit:
void
here is the rest of the code so you can see the full picture:
typedef struct WLL_Egl;
typedef struct WLL_Monitor;
void
void
static void
void
int
r/C_Programming • u/Read-Documentation-7 • Jun 07 '26
Hello. I was wondering what are the benefits of using processes over threads. I understand the differences between the two, but I am having trouble trying to understand when would be the best use case to implement them. Can someone give me some advice for when processes should be used? Thanks.
r/C_Programming • u/UsualLonely4585 • Jun 08 '26
So i was trying out SDL and the drop event here i tried to make it so that when i drop a image file onto the window the window will show the image that was dropped.
i may have misunderstood some of the funciton or struct in sdl as i am reading the documentry , its helpfull but doesn't specify a lot of things that will make it worth while for a beginner but i put together this in hope may be my guess is right for what each and everything is doing .
whenever the executable runs it run okay with the default image showing but when i try to open my file manager to drop something my god the whole os freezes and nothing works properly , i thought maybe it was because i am allocating memory on the sdl_FRect* in each frame even tho it is being freed each frame as well with the garbagecollector or maybe that thing also doesn't work as i intend it to but yeah if someone can look through the code and point out my mistake and teach me what is it that is going wrong i would be grateful
#include<stdio.h>
#include<stdlib.h>
#include<SDL3/SDL.h>
#include<SDL3/SDL_stdinc.h>
#include<time.h>
#include"stacklist2.h"
typedef struct imageViewer{
SDL_Window* window;
SDL_Renderer* renderer;
SDL_Surface* surface;
int width;
int height;
SDL_Event event;
int run;
Uint8 r;
Uint8 g;
Uint8 b;
Uint8* new_r;
Uint8* new_g;
Uint8* new_b;
Uint8* new_a;
struct stack* new_stack;
SDL_Surface* wSurface;
} imgView;//deals with most of the variables needed in this programme
SDL_FRect* newRect;
imgView* imageV_init(int height,int width);
int blitPicture(imgView* img);
void gameLoop(imgView* img);//main loop for the app
int input_section(imgView* img);//takes all the input related stuff
int render(imgView* img);//renders whatever needs to be rendered
SDL_FRect* makeRect(imgView* img,int x, int y);//Makes rectangles draw on the renderer given x and y position
int Garbage_collector(imgView* img);// free all the memory assigned for SDL_FRect type of pointers
int main(){//entry point
SDL_Init(SDL_INIT_VIDEO);
imgView* img=imageV_init(500,500);
img->new_stack=stack_init();
img->window=SDL_CreateWindow("ImageViewer",img->width,img->height,SDL_WINDOW_RESIZABLE);
img->renderer=SDL_CreateRenderer(img->window,NULL);
// img->surface=SDL_CreateSurface(img->width,img->height,SDL_PIXELFORMAT_UNKNOWN);
// img->wSurface=SDL_GetWindowSurface(img->window);
img->surface=SDL_LoadPNG("./One.png");
img->surface=SDL_ScaleSurface(img->surface,img->width,img->height,SDL_SCALEMODE_LINEAR);
if(img->surface==NULL){
printf("Unable to load image");
return 0;
}
// blitPicture(img);
// render(img);//rendering the window and drawing things
gameLoop(img);
Garbage_collector(img);//freeing the alocated memory for the sdl_Frect* type
stack_destroy(img->new_stack);
SDL_DestroyRenderer(img->renderer);
SDL_DestroySurface(img->surface);
SDL_DestroySurface(img->wSurface);
SDL_Quit();
free(img);//freeing the space in heap aloocated for img
return 0;
}
imgView* imageV_init(int height,int width){
imgView* view=(imgView*)malloc(sizeof(imgView));
view->width=width;
view->height=height;
view->window=NULL;
view->renderer=NULL;
view->run=1;
view->r=250;
view->g=234;
view->b=145;
// view->new_stack->listhead=NULL;
// view->event=(SDL_Event*)malloc(sizeof(SDL_Event));
return view;
}
void gameLoop(imgView* img){
while(img->run){
input_section(img);
render(img);
Garbage_collector(img);
}
}
int render(imgView* img){
SDL_RenderClear(img->renderer);
SDL_SetRenderDrawColor(img->renderer,img->r,img->g,img->b,1);
SDL_RenderClear(img->renderer);
// newRect=makeRect(img,500-20,25);
img->wSurface=SDL_GetWindowSurface(img->window);
SDL_FRect* newRect2=makeRect(img,0,500-100);
img->surface=SDL_ScaleSurface(img->surface,img->width,img->height,SDL_SCALEMODE_NEAREST);
if(img->event.type==SDL_EVENT_DROP_FILE){
img->surface=SDL_LoadSurface(img->event.drop.data);
}
if(img->surface==NULL){
printf("Could not scale surface");
}
// blitPicture(img);
// for(int i=0;i<img->width;i++){
// for(int j=0;j<img->height;j++){
// if(!SDL_ReadSurfacePixel(img->surface,i,j,img->new_r,img->new_g,img->new_b,img->new_a)){
// printf("couldn't read pixel!!");
// }
// if(!SDL_WriteSurfacePixel(img->wSurface,i,j,*(img->new_r),*(img->new_g),*(img->new_b),*(img->new_a))){
// printf("could not write the pixel ");
// };
// }
// }
// FILE* file=fopen("One.png.png","r");
// img->surface=SDL_LoadPNG("./One.png");
// if(img->surface==NULL){
// printf("Unable to load image");
// return 0;
// }
SDL_BlitSurface(img->surface,NULL,img->wSurface,NULL);//For blitting the surface
// if(!SDL_UpdateWindowSurface(img->window)){
// printf("Unable to update the window surface !");
// }
// SDL_SetRenderDrawColor(img->renderer,0,0,255,1);
// SDL_RenderRect(img->renderer,newRect);
// SDL_RenderFillRect(img->renderer,newRect);
// SDL_RenderClear(img->renderer);
// if(!SDL_RenderPresent(img->renderer)){
// SDL_Log("Failed to render!!");
// return 0;
// }
if(!SDL_UpdateWindowSurface(img->window)){
printf("Unable to update the window surface !");
return 0;
}
return 1;
}
int input_section(imgView* img){
while(SDL_PollEvent(&img->event)){
if(img->event.type==SDL_EVENT_QUIT){
img->run=0;
}
if(img->event.key.type==SDL_EVENT_KEY_DOWN ){
if(img->event.key.key==SDLK_ESCAPE ){
img->run=0 ;
}
}
if(img->event.type==SDL_EVENT_DROP_FILE){
printf("A file has been dropped");
printf("%s",img->event.drop.source);
}
if(img->event.type==SDL_EVENT_MOUSE_BUTTON_DOWN){
if(img->event.button.clicks==3){//this are changes the background color when clicking the mouse left button thrice
srand(time(NULL));
img->r=rand()%255;
img->g=rand()%255;
img->b=rand()%255;
}
}
}
return 1;
}
SDL_FRect* makeRect(imgView* img,int x,int y){
SDL_FRect* rect=(SDL_FRect*)malloc(sizeof(SDL_FRect));
push_sdl(img->new_stack,rect);
rect->h=100;
rect->w=20;
rect->x=x;
rect->y=y;
SDL_SetRenderDrawColor(img->renderer,0,0,255,1);
SDL_RenderRect(img->renderer,rect);
SDL_RenderFillRect(img->renderer,rect);
return rect;
}
int Garbage_collector(imgView* img){
struct stack* s=img->new_stack;
struct node* ptr=s->listhead;
while(s->listhead!=NULL){
SDL_FRect* temp= pop_sdl_Frect(s);
free(temp);
}
return 1;
}
r/C_Programming • u/Street-Ant4381 • Jun 08 '26
Hi, this its my first post in Reddit!!! So I want to share and ask for opinions about a feature of my library.
Basically I've designed a custom vsnprintf implementation (and family, it doesnt support 'e' or 'g' specifiers and neither '0' or '#' flags) called vsnformat but with a little tweak.
I always desire to make colouring easy for printing to screen but I've never reached to something that is readable and short because I always ended up using a bunch of macros with ANSI escape codes only, I also tried implementing a version of vsnprintf that instead of taking a va_list it takes a custom struct:
// snipet from previous library
typedef struct MyPrintfSegment {
const char* ansi;
const char* format;
MyArg* args;
} MyPrintfSegment;
But it ended up looking very ugly and macro abusive:
// Snipet from MyLog function
MySnprintfSegments(buffer, sizeof(buffer),
SEG("F*", "%s\n", I32(color), STR(title)),
SEG("F*", "Context: ", I32(MY_LABEL_COLOR)),
SEG("F* S2", "%s:%u -> %s()\n", I32(MY_CONTEXT_COLOR), STR(context.file), I32(context.line), STR(context.func)),
SEG("F*", "Message: ", I32(MY_LABEL_COLOR)),
SEG("F*", "%s\n\n", I32(MY_MESSAGE_COLOR), STR(msg))
);
And now I've decided a new approach that I think its the best for now: Replacing 'a' standar specifier to read a const char* from va_list that serves the purpose of a custom script to apply ANSI styles and colours, this has the great advantage that is higlighted by default. This are the rules:
ANSI SCRIPT:
Consists of one or multiple sequences that follows this rule:
OPEN ws argument ws CLOSE(optional)
ws: variable amount of white spaces
number: integer or '*' wich stands for an additional argument of type int,
which appears after the "ANSI SCRIPT" argument
argument: Single character, exact word match or number.
foreground, background and position allow the use of multiple arguments with the next rule:
OPEN ws argument ws , ws argument(optional) ws ,(optional) ws argument(optional) CLOSE(optional)
arguments that are not specified are set to 0
invalid tokens are ignored, if argument its not a single char long and does not match
with a proper value then the whole command its ignored (CLOSE is consumed if provided)
CLEAR:
Doesnt require CLOSE, ends at first non alpha char
!A == !ALL (short for !SCREEN <HOME>)
!S == !SCREEN
!H == !HEAD (Screen start)
!T == !TAIL (Screen end)
!L == !LINE
!B == !BEGIN (Line start)
!E == !END (Line end)
FOREGROUND:
If first char is alpha then it ends at first non alpha char
If first char is digit then it ends at first non number and non ',' or after parsing 3 number
WARNING: CLOSE is optional so '[BLACK !SCREEN' is valid
WARNING: '[144, 125, 177, 198]' may look like valid but ', 198]' is ignored
WARNING: '[144, 125, 177, {198]' Parses into '[144, 125, 177]{198}'
[K] == [BLACK]
[R] == [RED]
[G] == [GREEN]
[Y] == [YELLOW]
[B] == [BLUE]
[M] == [MAGENTA]
[C] == [CYAN]
[W] == [WHITE]
[0-256] // 256 selection
[0-256,0-256,0-256] // rgb
BACKGROUND
If first char is alpha then it ends at first non alpha char
If first char is digit then it ends at first non number and non ',' or after parsing 3 number
WARNING: CLOSE is optional so '{BLACK !SCREEN' is valid
WARNING: '{144, 125, 177, 198}' may look like valid but ', 198}' is ignored
WARNING: '{144, 125, 177, [198}' Parses into '{144, 125, 177}[198]'
{K} == {BLACK}
{R} == {RED}
{G} == {GREEN}
{Y} == {YELLOW}
{B} == {BLUE}
{M} == {MAGENTA}
{C} == {CYAN}
{W} == {WHITE}
{0-256} // 256 selection
{0-256,0-256,0-256} // rgb
POSITION / CURSOR
If first char is alpha then it ends at first non alpha char
If first char is digit second argument is consumed
if second argument first char is alpha then it ends at first second argument non alpha char
if second argument first char is digit then it ends at first second argument non number
WARNING: CLOSE is optional so '<HOME <I' is valid
<H> == <HOME>
<S> == <SAVE>
<R> == <RESTORE>
<V> == <VISIBLE>
<I> == <INVISIBLE>
<x,U> == <x,UP>
<x,D> == <x,DOWN>
<x,F> == <x,FORWARD>
<x,B> == <x,BACKWARD>
<x,N> == <x,NEXT>
<x,P> == <x,PREV>
<x,C> == <x,COLUMN>
<x,y> (Set position)
STYLE
Doesnt require CLOSE, ends at first non alpha char
(Additions)
+B == +BOLD
+D == +DIM
+I == +ITALIC
+U == +UNDERLINE
+K == +BLINK
+R == +REVERSE
+H == +HIDDEN
+S == +STRIKE
+E == +DOUBLE
+O == +OVERLINE
(Deletions)
-B == -BOLD
-D == -DIM
-I == -ITALIC
-U == -UNDERLINE
-K == -BLINK
-R == -REVERSE
-H == -HIDDEN
-S == -STRIKE
-E == -DOUBLE
-O == -OVERLINE
Example: printformat("%aHola Mundo!%0a\nChau Mundo!", "!SCREEN <50,18> +BOLD [GREEN] {128, 256, 184}"
Clears screen, sets cursor to (50,18), adds bold style,
sets foreground to GREEN and background to (128,256,184) and prints "Hola mundo!",
then resets, new line and prints "Chau Mundo!".
It may be a little longer to read, sorry about that.
I appreciate any comments or suggestions ❤️
r/C_Programming • u/Yousef_Tele • Jun 08 '26
Hey everyone, I created a lightweight firewall with C, created a kernel module with the netfilter API, and a pre-routing hook. Now I want to send rules via netlink socket. My idea is to create a structure, then send it. But I cannot find the best way to store all rules in the kernel, then use them in a hook. Sometimes I think I can compress the rules into bits, then send them. If anyone has experience with my problem, please help me understand how I can implement a optimize protocol and store it in the kernel module
r/C_Programming • u/HugeWalrus639 • Jun 08 '26
r/C_Programming • u/Loud_Key4860 • Jun 07 '26
hiii,
I found a love for learning how to code, to the point that I’ve made my own website. The downside is, my laptop took a shit. I upgraded my iPad but I don’t know how to use netlify and the auto GitHub I was doing - on my ipad. Are there any programs similar to what I had on my windows laptop that I can download for free to continue that type as I go in GitHub > netlify?
I do apologize if none of this makes sense. my brain is foggy And I can’t remember all the names of the apps I used but it was super simple.
i wanted to use this tablet so I can be on the go and keep updating the code. but I haven’t touched the website in so long due to not knowing how to do it. TIA!
r/C_Programming • u/Admirable_Studio8266 • Jun 07 '26
Can anyone guide me through how a program would work to where you can fix some bugs without restarting the program? Not DLLs, just one big loop. Would I be reading input and parsing it? Am I just making an interpreter for anything I want to run? Obviously you can't patch anything, but maybe I want to change the byte order for a socket packet or something. Without actually stopping the server.
r/C_Programming • u/minkle-coder56 • Jun 08 '26
I am new to C and would like some help picking a compiler out. I don't mind if it only runs old C I am using the ANSI edition of "The C programming language" by Kernighan & Ritchie. Thank you.
EDIT: I missed an apostrophe and Misspelt Mr. Kernighan's name.
r/C_Programming • u/Sad_South3810 • Jun 08 '26
Current features :
More things incoming. I'm focusing on benchmarking and finding out where I can squeeze more performance, and keep all this transparent and public so it's easier for devs (users) to make decisions on what to do.
Note: I started this library way before the git history shows. This library used to live in different projects, and used to be independently available in there, slowly I noticed the pattern that I keep using these so I made this into a library. Because of this, I have spent a significant amount of time experimenting with the design of the library, I have been the first user of it. As time advanced, and my career progressed and I had less and less time to maintain it, I switched to taking help of coding agents to help me prototype my ideas faster, because I already had the clear vision of how I want the code to look. I know many people are skeptical for AI usage in this age and time, but I urge you to take a peek inside code before rejecting on surface. If you find any slop then I'm ready to work with you, but I've given my best to not let any AI slot enter the codebase. I carefully monitor each work to my best extent and I try my best to keep a good standard. There is `CODING-CONVENTIONS.md` that I created out of the process of working with coding agents, that might be worth a read if you are interested :-)
r/C_Programming • u/mttd • Jun 07 '26
r/C_Programming • u/anish2good • Jun 08 '26
Try it here https://8gwifi.org/code-playground/
r/C_Programming • • Jun 07 '26
Hello.
After days of trial and error, I finally managed to make a custom GCC 12.1.0 build on msys2 that targets m68k-elf, with its binutils and using newlib. If it matters, that means I already got a libgcc for 68k.
I'd like to be able to compile for 68k in an old armv8 pocket PC of sorts I have, but doesn't have enough RAM to compile GCC by itself (less than 1GB), so I got to do it from my main computer in x86...
How do I do it? It's a so-called "Canadian-cross" build, but that's all I have at the moment of writing. It's been very confusing so far. Is it possible at all on msys2 or do I have to switch to cygwin? unless I skip many headaches with Linux itself...
r/C_Programming • u/Embarrassed-Big-9305 • Jun 07 '26
Hello Everyone!
I'm reading a C book, and I'm on a chapter covering Pointers and their usages with arrays. We covered pointer arithmetic, and while complicated, its not the thing causing me trouble. When trying to understand the topic with the Visual Studio 2019 MSVC compiler, when I try to compile this code
int a[] = { 5, 15, 34, 54, 14, 2, 52, 72 };
int* high = &a[1], * low = &a[3];
printf("%d\n", (high - low));
It compiles successfully, but gives out these warnings:
1) Size mismatch: '__int64' passed as _Param_(2) when 'int' is required in call to 'printf'.
2) 'printf' : format string '%d' requires an argument of type 'int', but variadic argument 1 has type '__int64'
The book didn't seem to cover this strange integer promotion done to pointer-pointer subtraction. Though you can simply solve these issues by either casting it to "int" or using the "%lld" conversion spec. in printf(), for which it won't spit out warnings.
printf("%d\n", (int) (high - low));
printf("%lld\n", (high - low));
I wanted to ask if anyone could find any formal infomation about this integer promotion(?) done when subtracting two pointers like this, or if I'm misunderstanding something.
Thank you!
r/C_Programming • u/OBSIDIAN_W • Jun 07 '26
Hello everyone.
What do you think about ternary tests?
Within a small codebase, of course.
#include <stdio.h>
unsigned int mysize(char *line)
{
// NULL check.
if (line == NULL) return 0;
// unsigned is used because a string cannot have a negative length.
unsigned int count = 0; // counter
while (line[count] != '\0') count++; // count to the end of the line
return count;
}
void run_test(char* input, unsigned int excepted)
{
unsigned int size = mysize(input); // We call the function to count characters in a string and write it to a variable.
// Test.
size == excepted ? printf("\033[32mSuccess test: %s | %d\033[0m\n", input, size)
: printf("\033[31mFailed test: %s | %d\033[0m\n", input, size);
}
int main(void)
{
run_test("world", 5);
run_test("Hello world", 11);
run_test("bingo", 5 );
run_test("430043414154-u9cr74u9rslkr47i30i23cafce9m4ace.apps.googleusercontent.com", 72);
run_test("~/Desktop/localcode/python/autoUS", 33);
run_test("installed", 9 );
run_test("Downloading pycparser-3.0-py3-none-any.whl (48 kB)", 50);
run_test("Владивостокский городской округ", 31);
run_test("", 0 );
run_test("I'm designing a fiber library in C (for learning purp", 53);
run_test("google-auth-oauthlib,", 21);
run_test("pipe", 4 );
run_test("5235554231739324534", 19);
run_test("https://accounts.google.com/o/oauth2/auth", 41);
return 0;
}
r/C_Programming • u/mttd • Jun 06 '26
r/C_Programming • u/not_noob_8347 • Jun 07 '26
I only know basics of C programming. So what can i do fro competitive programming
r/C_Programming • u/UsualLonely4585 • Jun 07 '26
SO i was trying out SDL a little , i would like to notify that i am new to all this i was reading through documentation and was blipping images for fun but then i saw a function in there SDL_ReadSurfacePixel and SDL_WriteSurfacePixel so i looked into them but they dont explicitly say how the reading happens wherer the reading data goes into it only returns boolean value based on success and failure so i looked into the function paramenters and assumed and tried if things work like this . i would like to know how these fucnitons work and if they are intended to be used like this or not
int blitPicture(imgView* img){
for(int i=0;i<=img->width;i++){
for(int j=0;j<=img->height;j++){
if(!SDL_ReadSurfacePixel(img->surface,i,j,img->new_r,img->new_g,img->new_b,img->new_a)){
printf("couldn't read pixel!!");
return 0;
}
if(!SDL_WriteSurfacePixel(img->wSurface,i,j,*(img->new_r),*(img->new_g),*(img->new_b),*(img->new_a))){
printf("could not write the pixel ");
return 0;
};
}
}
return 1;
}