Jan 28, 2016 04:36 AM
(This post was last modified: Jan 28, 2016 02:40 PM by Alberto9998.)
Hey guys and girls, so I just realized i'm stupid. Like really stupid, and wanna kill myself, but before I do that, I need this solved... any help will be wellcome
So I need a script which reads and rewrites a file in .c, and I need to be able to open it with gcc.
I am learning pyton, just started a few days ago, and I understand how to do the rewriter script, and I did it, but I need that script in C, and I need to read it in gcc.
and I have no clue now where to start because I spent a lot of time like an idiot trying to read the python programed script with gcc xD thats why I say im stupid, and I need that for today, and I'm crying.
so this is my python rewriter which i got from a webtutorial while learning.
And I need someone smarter than me (not dificult hah) to write that in C, and working in gcc xD
I thx a lot for any help, and yeah.. I will own my life and dignity to the one helping me xD or more than one...
Edit:
the 2 links:
*1
*2
So I need a script which reads and rewrites a file in .c, and I need to be able to open it with gcc.
I am learning pyton, just started a few days ago, and I understand how to do the rewriter script, and I did it, but I need that script in C, and I need to read it in gcc.
and I have no clue now where to start because I spent a lot of time like an idiot trying to read the python programed script with gcc xD thats why I say im stupid, and I need that for today, and I'm crying.
so this is my python rewriter which i got from a webtutorial while learning.
Code
from sys import argv
script, filename = argv
print "We're going to erase %r." % filename
print "If you don't want that, hit CTRL-C (^C)."
print "If you do want that, hit RETURN."
raw_input("?")
print "Opening the file..."
target = open(filename, 'w')
print "Truncating the file. Goodbye!"
target.truncate()
print "Now I'm going to ask you for three lines."
line1 = raw_input("line 1: ")
line2 = raw_input("line 2: ")
line3 = raw_input("line 3: ")
print "I'm going to write these to the file."
target.write(line1)
target.write("\n")
target.write(line2)
target.write("\n")
target.write(line3)
target.write("\n")
print "And finally, we close it."
target.close()And I need someone smarter than me (not dificult hah) to write that in C, and working in gcc xD
I thx a lot for any help, and yeah.. I will own my life and dignity to the one helping me xD or more than one...
Edit:
the 2 links:
*1
Code
int main(){
FILE* file = fopen("file.txt","r");
char * buffer = NULL;
int i, c;
c = fgetc(file);
while(!feof(file))
{
buffer = (char*)realloc(NULL, sizeof(char));
i = 0;
while( c != '\n')
{
buffer[i] = c;
i++;
buffer = (char*)realloc(buffer, (i+1)*sizeof(char));
c = fgetc(file);
}
buffer = (char*)realloc(buffer, (i+2)*sizeof(char));
buffer[i] = c;
buffer[i+1] = 0;
printf("%s", buffer);
free(buffer);
c = fgetc(file);
}
close(file);
}*2
Code
int wordCounter {
P=0;
for(x=0;x<long;x++){
if(cad[x]==' ' && x!=499 && cad[x+1]!= ' '){
P++;
}
}
return 0;
}


![[Image: MtOuiI0.png]](https://i.imgur.com/MtOuiI0.png)
