Sorry people, I have tryed to change the scanf's with fgets, but I didn't make it! I gave up. I suppose the programm will stay as it is.
Type: Posts; User: antonis
Sorry people, I have tryed to change the scanf's with fgets, but I didn't make it! I gave up. I suppose the programm will stay as it is.
I am a newbie too, but except the thing cwr wrote, I cant see of something that could become simpler, or in less lines. I think it's OK.
Thanks DavT, I will try to replace the scanf's with fgets as soon as I go back home today. I will report when I have done this.
read i
for k=0; k<=i ++i
k=k->next
--------------------
then insert the i after k
you have just to adjust the ->s. Its like this
k->next->prev=i
i->next=k->next
k->next=i
i->prev=k
I have uploaded to my homepage:
homepage
Here you have to download the files from Project 2! nvi383.c is my code the others are for compilation (memory.c&memory.h about using MALLOC instead of...
No I used flush too, but the 2 prompts are still there. I had to send it before 1 hour, so I put a comment explaining what doesn't work. It's minor to the whole programm but I have spent so many...
for you maybe! But I won't play this game any longer.
Of course I don't think I'm brilliant, I am absolutely a newbie.
The teacher first tells you the right thing and then corrects your mistakes.
I don't have anything against laughing but against...
I have:
else if (l=='b'){
/*Dialog to insert a new line before current line.*/
printf("Insert the new line:\nTEEDI>");
fflush(stdout);
...
Yes you helped....
But why doesn't it stay at the prompt and goes directly to the function? Should I change ti to scnaf again?
AA
@cwr: This code is OK but here:
else if (l=='b'){
/*Dialog to insert a new line before current line.*/
printf("Insert the new line:\nTEEDI>");
...
else if (l=='b'){
/*Dialog to insert a new line before current line.*/
printf("Insert the new line:\nTEEDI>");
fgets(newline, MAXLINE,stdin);
...
Thanks barnzey it now worked. Just one more question stdin means it reads from the keyboard????
@durban: what do the std::cin. mean with std::cin.getline(line, 256);it doesnt get compiled. When using just getline(line, 256); I get segmentation immidiatelly when I run the prog.
@Quantum:Your code gives this while compiling
/home/plutonas/tmp/ccADhe1V.o(.text+0x2a): In function `main':
: warning: the `gets' function is dangerous and should not be used.
and for fgets,...
I use the assigment operator at printf because else I get segmentation. But actually I dont need to read and write a line(so printf is not actually needed), I can do this by another way: ...
#include <stdio.h>
main()
{
char *line;
scanf("%s",&line);
/*NOW USE THE TEXT LINE WHILE CALLING A FUNCTION*/
printf("%s",&line);
Here,
Hi
I want to make a programm that takes a text line from the keyboard, and then I want to use the line as a parameter in a function.
Here is my code:
#include <stdio.h>
main()
{
char line;...
void InsertAfter(struct list *buffer, char *newline)
{
//if currentpos is last line: I have to add....
struct node *makeNode(char *newline);
struct node...
Hi everybody!
I asked yesterday something about my project: TOPIC
and now that I have almost finished I have problems with the last function that inserts a new line after the current. Here there...
Salem! I don't know how to thank you. :)
Really thanks a lot.
It works, I have been a lot further with my project(thanks to your help I could make 2 more functions: InsertLine and DeleteLine also...
These are my structs:
struct node {
char *line;
struct node *prev;
struct node *next;
};
struct list {
I did it but with prev instead of next as it starts from the last line, and I could not make the *next pointer while reading the file. I think it should work but : segmentation fault! I HATE...
I have to make a programm that among others outputs a text stored in a struct node (line by line), in a file. I use fputs.
Here is the function PrintFile that prints the file:
void...
I have problems to allocate the data....
I think ist very complicated for a newby like me.
So, I want to use a struct node, where very line is a node,
and a struct list.
here the function again...