Click here to Skip to main content
15,562,816 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
C
#include <stdio.h> 
#include <stdbool.h> 
#include<string.h>
//trying to make map of key ,value so two column but many row
int len[50][2]; 
void Return(char **a,char **b,FILE *ftp){
	char ch;
bool str=1;
int k,v,line;
k=0;
v=0;
line=0;
int i=0;

	//here a=key and b=value;
//trying to read a file and load in len array 
//suppose file contain
//key:value,key2,value2...
while((ch=fgetc(ftp))!=EOF){ if(ch==':'){
				continue;
			}
			if(ch==','){ /*code*/ len[line][1]=k; len[line][2]=v; line++; continue;
			}
			//string starter and ender
			if(ch=='"'){ if(str=0){str=1;continue;}else{str=0;continue;}}
			//ender
			if (str==1){ a[line][k]=ch;k++;
			}
			if (str==0){ b[line][v]=ch;v++;}

			i++;
		}
}
void sd(char** a[],int w){ a[w][len[w][1]]='\0';}

char returnValue(char *k,char *x ,char *v){ int i=0; do{if(strcmp(&k[i],&x[i]))return v[i];break;} while(i<50);}

void charToString(char a[],int n){
a[n+1]='\0';
} 
int main(int arg,char argv){
	FILE *ftp;ftp=fopen("/home/chintu/Documents/c.txt","r"); if(!ftp)printf("file not found\n");else{
		/* if(ch=='"'){ ysize_t size;
		//knowing file size
		fseek (ftp , 0 , SEEK_END); size = ftell (ftp); rewind (ftp);
		//knowing file size completed j indicate the temp count*/
char key[50][50]; char value[50][50];
		Return(&&key,&&value,ftp);

	printf("%s\n",value);
	}
	return 0;
}

a.c: In function ‘main’:
a.c:34:17: error: label ‘value’ used but not defined
   34 |                 Return(&&key,&&value,ftp);
      |                 ^~~~~~
a.c:34:17: error: label ‘key’ used but not defined
make: *** [Makefile:4: run] Error 1

shell returned 2


What I have tried:

I got many errors solved them the key,value are declared but showing label not found error
Posted
Updated 23-Oct-22 8:51am
v2
Comments
Richard Deeming 16-Jul-21 10:07am    
Well, this wins the prize for the least readable code I've seen today!

I'm not sure whether it's your code, or whether the site has messed up the formatting somehow. But there seem to be a lot of missing line breaks, meaning things are squashed onto single lines when they shouldn't be.

The compiler doesn't care, but anyone else trying to read your code does!

Don't call functions the same name as keywords - even if you use use an unpper case character to distinguish them to the compiler, it makes a human beings job a lot, lot harder - in fact, most of that code makes it hard to read, from the poor indentation to the variable name schoise, via pretty much everything else inbetween...

C has two operators you use ampersands: "&" - the 'address of' operator, and "&&" - the logical AND operator.

You're trying to use the later when you shouldn't: the name of an array is a pointer to the first element so you shouldn't need to take the address of the array at all.

C
void PrintMyArray(int arr[][3])
    {
    for (int i = 0; i < 3; i++)
        {
        for (int j = 0; j < 3; j++)
            {
            printf("%u ", arr[i][j]);
            }
        printf("\n");
        }
    }
int main()
    {
    int data[3][3] = {{1, 2, 3}, {11, 12, 13}, {21, 22, 23}};
    PrintMyArray(data);
    return 0;
    }
 
Share this answer
 
There are three ways && can be used:

1) As a logical operator:
C
if (something && something_else)

2) As a "label value" operator, which takes the address of the specified label and stores it in a pointer:
Labels as Values (Using the GNU Compiler Collection (GCC))[^]

3) In C++ 11, as an "rvalue reference" operator:
C++ rvalue references and move semantics for beginners - Internal Pointers[^]

Your code is using option 2 - the "label value" operator. Since you haven't defined labels called key or value, it gives you the error mentioned in your question.
 
Share this answer
 
Comments
Chintu sharma 16-Jul-21 10:47am    
Sorry I did not understand your post
I did not understand what are labels.
you can see both key and value which are multidimensional array.
I tried to fit according to compiler said.
Richard Deeming 16-Jul-21 10:50am    
Labels are used with the (not recommended) goto statement:
goto statement - cppreference.com[^]

Your code is trying to take the address of a label which has not been defined, when you actually want to take a pointer to a pointer to the variable which you have defined.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900