answersLogoWhite

0

scanf() is an input function.

It takes an input from the user and store it in a variable.

Since "&" is a reference operator and it represents the memory location of the variable.

String is a type of array and an array consumes more than one memory address.
It is obvious that no need to use "&" operator for an entire array.

For an individual data type like int , char , float etc , "&" is needed but for an array no need to use "&".

User Avatar

Wiki User

15y ago

Still curious? Ask our experts.

Chat with our AI personalities

LaoLao
The path is yours to walk; I am only here to hold up a mirror.
Chat with Lao
DevinDevin
I've poured enough drinks to know that people don't always want advice—they just want to talk.
Chat with Devin
CoachCoach
Success isn't just about winning—it's about vision, patience, and playing the long game.
Chat with Coach
More answers

Because the name of the string (array) is sufficient to pass the address of the first element.

By the way - it is not safe to pass strings to scanf() without doing bounds checking.

User Avatar

Wiki User

12y ago
User Avatar

Add your answer:

Earn +20 pts
Q: Why dont you write ampersand while using strings in scanf?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Continue Learning about Engineering

Multiplication table using do while loop?

#include void main() { int i=2,m,n; printf("enter number"); scanf("%d",&n); do { m=i*n; printf("%d*%d=%d\n",n,i,m); i=i+1; } while (i<=10); }


How to write a program that ask user to enter numbers until user enter- 0 then find the biggest of entered numbers in C programming using while or do while?

int i, largest=0;do { scanf ("Enter a number (0 to exit): %d", i); if (i>largest) largest=i; } while (i!=0); printf ("Largest number is: %d\n", largest);


Do while loop program in c for printing odd numbers?

#include<stdio.h> main() { int a,i=1; printf("Enter max no"); scanf("%d",&a); do { printf("%d",i); i=i+2; }while(i<=a); }


What types of database exist in c plus plus?

#include <stdio.h> main() { FILE *a; int sno,tm,em,mm,scm,sm,hm; char sname[20],any[1]; clrscr(); a=fopen("student.dat","a"); do { printf("Enter Student Number : "); scanf("%d",&sno); printf("Enter Student Name : "); scanf("%s",sname); printf("Enter Telugu Marks : "); scanf("%d",&tm); printf("Enter English Marks : "); scanf("%d",&em); printf("Enter Maths Marks : "); scanf("%d",&mm); printf("Enter Science Marks : "); scanf("%d",&scm); printf("Enter Social Marks : "); scanf("%d",&sm); printf("Enter Hindi Marks : "); scanf("%d",&hm); fprintf(a,"%d %s %d %d %d %d %d %d\n",sno,sname,tm,em,mm,scm,sm,hm); printf("Do you wish to continue(Y/N)"); scanf("%s",any); }while(strcmp(any,"y")==0); fclose(a); }


When do we use an address operator in c'?

In C we use & operator while giving address of some variable to some pointer variable. & operator is also used in scanf().