Anyone good in C ? Here's the program: #include <stdio.h> /* This program removes a string from another string */ void RemoveString(Source, Start, NumChar) char Source[]; int Start, NumChar; { int i = 0, j = 0; char Test[50]; while ( Source != '\0' ) { Test = Source; i++; } for ( i = 0; i < NumChar; i++ ) Source[Start+ i] = Test[Start + NumChar+ i]; Source[Start + i] = '\0'; printf ("%s\n", Source); } main() { RemoveString( "This does not work", 10, 4); } Here's how it works, or how it is supposed to work: The program calls the RemoveString function with three arguments: 1. The string 2. The index in the string where the string that's to be taken out starts. 3. The number of letters that the string has. In this example 10 refers to 'n' , 4: 4 letters("not "). So at the end, the output of the program should be: "This does work", since the not, plus the space has been taken out. But I get an execution error at this line: Source[Start+ i] = Test[Start + NumChar+ i]; And I don't understand why. What I want to do is to copy the rest of the string (what is after the word to be taken out), over the location of that particular word. so "Start + i" is the index of the first letter (i being 0 at the start of the loop), in which the letter after the word to be taken out should be copied (Start = 10 + Numchar = 4 + i = 0 = 14: which represents 'w' in the string. So 'w' should be copied where 'n' is, 'o' where 'o' is, 'r' where 't' is, and so on, until 'i' is equal to Numchar. After that, I copy the NULL character to the end of the string, and display it. I'd like to know what the FUCK is wrong with that FUCKING line. It seems right to me !!!!!!!!!!! EDIT: I know this is a bit unreadable but I can't seem to be able to make the tabs in here. Initially, I wanted it to be Source[Start + i] = ..................I found it..
Ok never mind, I just found out what the problem was. I can't change the Source string, so I have to copy the answer in the Test string. The Test string was actually there for that exact purpose, I just mixed them up. I had to ask for help here only to find out what the problem was by myself....what a fucking idiot !!!!!!!!!!!!!!!! So the line should be: Test[Start+ i] = Source[Start + NumChar+ i]; Along with changes in the printf and when copying the NULL character.
For those that are interested: instead of : for ( i = 0; i < NumChar; i++ ) Test[Debut + i] = Source[Start+ NumChar + i]; the condition should be: i = 0; while ( Source != '\0' ) { Test[Debut + i] = Source[Start+ NumChar + i]; i++ }
lol, I dont think any one knows c programming here? I think I will be learning it, in a years time though!
It's not that complicated. You can easily learn the basics in a week or two. It's tougher than HTML, but then again, what's not ?
Ok, here's the final version: The variables, function and description are all in French. It took me a couple of days to figure how a function can return a string, just to realize that strings can't be returned, and that when you pass a string(thus an array) to a function, any changes that you make to it remain, unlike any other type of variables, so you don't even need to return it, you just need to make it available to the various functions where you need it, anyways, I should habve though of it because I knew it, I just didn'T remember. It's in moments like these that you wanna' take a baseball bat and DESTROY YOUR FUCKING SCREEN. #include <stdio.h> /* Ce programme extrait une chaîne d'une autre chaîne */ void EnleverChaine(Source, Debut, NbreLettres, Reponse) char Source[], Reponse[]; int Debut, NbreLettres; { int i = 0, j = 0; while ( Source != '\0' ) { Reponse = Source; i++; } i = 0; while ( Source != '\0' ) { Reponse[Debut + i] = Source[Debut + NbreLettres + i]; i++; } Reponse[Debut + i] = '\0'; } main() { char Chaine[50] = "Criss de cave d'innocent"; char Reponse[50]; EnleverChaine( Chaine, 6, 8, Reponse); printf ("%s\n", Reponse); } "Criss de cave d'innocent" could be trabslated into :"Fucking idiot fuck" (if that's even a sentence). and the output would be: "Criss d'innocent" meaning "Fucking fuck" I chose this example because I was frustrated at the time.
you guys a all older then me buy at least 4 years and i know more then you i am 15 and already know php, perl, html, python, and past the basics in c++ i also can use pretty much every 3d image program out there better then i can use a toothpick lol well im gunna shut up and stop bragging
I don't have the patience for programming. I'm a bitter, bitter man. I do some HTML tags, but that's more psuedo-programming at best. I do it because it makes putting reivews up alot easier to have set the way I want.