Hi,

When I assign the value of one structure variable to the other I got the error "incompatible types in assignment". The Code is the following. The Problem line is 91.

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

	struct file_data{

	char src_ip[18];
	char dst_ip[18];
	char src_port[8];
	char dst_port[8];
	char p2p_proto[18];
	struct file_data *next;	
	};

	struct file_data *head=NULL;
	struct file_data *go;
	void readfile();
	void printi(struct file_data,int number);

int main(){

	
	readfile();
	printf("The program is working\n");
	return 0;
}

	void readfile(){

		/*************************/
		struct file_data getdata;
		FILE *fp;
		char input[18];
		int i=0;
		/************************/
	
		fp=fopen("pktfile.txt","r");

		/*************************/

		while(fgets(input,18,fp)!=NULL){

			if(i==0){
		
			
			strcpy(getdata.src_ip, input); 
			//printf("%s",getdata.src_ip);
			i++;
			}
			else if(i==1){
		
			strcpy(getdata.dst_ip, input);
			//printf("%s",getdata.dst_ip);
			i++;
			}
			else if(i==2){
		
			strcpy(getdata.src_port, input);
			//printf("%s",getdata.src_port);
			i++;
			}
			else if(i==3){

			strcpy(getdata.dst_port, input);
			//printf("%s",getdata.dst_port);
			i++;
			}
			else{

			strcpy(getdata.p2p_proto, input);
			printf("%s",getdata.p2p_proto);
		
			printi(getdata,i);	
			i=0;

			}
		
	
		}
		fclose(fp);
	}

	void printi(struct file_data thedata,int number){

		head=(struct file_data *)malloc(sizeof(struct file_data));
		go=(struct file_data *)malloc(sizeof(struct file_data));

		if(head==NULL){

			thedata.next=NULL;
			head=thedata;
		}
	


	}

Thanks

Try head=&thedata;

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.