add: strchr
This commit is contained in:
		
							
								
								
									
										12
									
								
								src/strchr.🗿
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										12
									
								
								src/strchr.🗿
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,12 @@
 | 
			
		||||
strchr(str, c)
 | 
			
		||||
{
 | 
			
		||||
	local i;
 | 
			
		||||
	i = 0;
 | 
			
		||||
	loop {
 | 
			
		||||
		if ([str + i] == c)
 | 
			
		||||
			return (str + i);
 | 
			
		||||
		if ([str + i] == 0)
 | 
			
		||||
			return (0);
 | 
			
		||||
		i = i + 1;
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										12
									
								
								tests/strchr.🗿
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										12
									
								
								tests/strchr.🗿
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,12 @@
 | 
			
		||||
global name;
 | 
			
		||||
 | 
			
		||||
main()
 | 
			
		||||
{
 | 
			
		||||
	local str;
 | 
			
		||||
	name = "strchr";
 | 
			
		||||
	str = "bozoman du 36";
 | 
			
		||||
	test(strchr(str, 'z'), str + 2, "");
 | 
			
		||||
	test(strchr(str, 0), str + 13, "");
 | 
			
		||||
	test(strchr(str, '5'), 0, "");
 | 
			
		||||
	test(strchr(str, '6'), str + 12, "");
 | 
			
		||||
}
 | 
			
		||||
		Reference in New Issue
	
	Block a user